Answer the question
In order to leave comments, you need to log in
How to run a Workerman Websocket server next to Apache?
There is an Apache server. It is running on port 80.
Project architecture
- workspace
-- api
-- js
-- img
-- css
-- views
--socket
-- app.js
-- index.js The socket
folder contains the sever.php file, which contains this the code:
<?php
use Workerman\Worker;
use PHPSocketIO\SocketIO;
require_once __DIR__ . '/vendor/autoload.php';
// listen port 2021 for socket.io client
$io = new SocketIO(3001);
$io->on('connection', function($socket)use($io){
$io->emit('listen', $msg);
});
Worker::runAll();
?>
php server.php start
angular
.module('kanban')
.factory('Socket', function (socketFactory) {
return socketFactory({
ioSocket: io.connect('http://[IP]:3001')
});
});
Answer the question
In order to leave comments, you need to log in
1) Look towards the client, google for "socket.io ERR_CONNECTION_TIMED_OUT"
2) What does Apache have to do with it? He does not participate in this scheme.
3) It seems to start correctly.
And by the way, the listen event is emitted on the server, you do not seem to process it on the client in any way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question