-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question #2
Comments
Hello! $socketio->send('localhost', 9090, 'message', 'Hello world!') I corrected the example in github
|
Hello and thanks for your response! I already tried that before and also now by viewing your actual php method. But it's exactly the same result, I can see the connect/disconnect but not the message. Any other ideas to check? |
You can run socketio in DEBUG. |
I just figure out that I had to set the environment variable DEBUG=* to What I get is: On 20 April 2015 at 09:42, Fail [email protected] wrote:
|
You have a transport error. Do you install socket.io server correctly? Are you use 'websocket' as transport? |
Yes I am using the websocket as transport (I didn't not change anything on I have a client side client like this: <script src="https://cdn.socket.io/socket.io-1.3.4.js"></script> <script src="http://code.jquery.com/jquery-1.11.1.js"></script> <script> var socket = io('http://localhost:1337/'); socket.on('connect', function(){ $('#messages').append("Connected"); }); socket.on('event', function(data){ $('#messages').append("Event"); }); socket.on('disconnect', function(){ $('#messages').append("Disconnected"); }); socket.on('user message', message); function sendMessage() { socket.emit('user message', $('#m').val()); $('#m').val(''); } function message (from, msg) { $('#messages').append($('').append($('').text(from), msg)); } </script> and is working fine with log: socket.io:server incoming connection with id lJ78DYYTFylGSE5QAAAA +17s Maybe it has something to do with the socket.io version? Thank you very much for your help! On 20 April 2015 at 17:25, Fail [email protected] wrote:
|
Yes, exactly the same packages should come from the PHP script. Which version Socket.io do you use? |
Node.js version v0.12.0 Thanks! On 20 April 2015 at 19:05, Fail [email protected] wrote:
|
Yes, it's my mistake. And please write that everything is OK ;) |
Sorry but not really:) Did you made a project example with the latest node js and socket.io and is Log: Thank you On 21 April 2015 at 06:18, Fail [email protected] wrote:
|
Ok. this is my nodejs code:
This is my test PHP code:
I use latest socket.io library. |
I copied all the code and still did not work. I decided to run node in socket.on('message', function (msg) { and run: node debug server.js The strange thing is when I run it like this, and the execution stop at the I don't want to spend more of your time but if you have any idea about this Thank you for all your help. On 21 April 2015 at 09:18, Fail [email protected] wrote:
|
It's so strange. Probably too fast PHP attempts to connect and send the message. Try inserting sleep in PHP code to send messages took place some time after the connection |
I did added a sleep for 2 seconds before the fwrite message and it's I appreciate your work and effort you gave into this. Thank you again! On 21 April 2015 at 11:49, Fail [email protected] wrote:
|
You need to read up until while you meet |
Can you explain more what do you mean with: You need to read up until while you meet "Sec-WebSocket-Protocol: websocket" I used it on Windows Azure and after I remove the http:// from this line it worked: |
When you receive a reply from the server, you need to keep track of the line |
Hi, I tried this, but it not working : `public function read($host = null, $port = null, $action= "message", $data = null, $address = "/socket.io/?EIO=2", $transport = 'websocket')
|
I'm using latest node.js and socket.io but I faced the same issue as this topic. Thanks. |
@psinetron , This is my socket.io server code: app.use(cors()); app.get('/', function(req, res){ io.sockets.on('connection', function(socket){ socket.on('message', function(msg){ socket.on('disconnect', function(){ http.listen(3000, function(){ Thanks. |
Hello,
I am trying to use your library in my cakephp application. I can successfully connect and disconnect to the node js server but I cannot send the message.
I write the client as in your examples:
$socketio = new SocketIO();
if ($socketio->send('localhost', 1337, 'Hello')) {
echo 'we sent the message and disconnected';
} else {
echo 'Sorry, we have a mistake :'(';
}
and for the server:
io.sockets.on('connection', function(socket)
{
console.log('Client connected.');
socket.on('disconnect', function() {
console.log('Client disconnected.');
});
socket.on('message', function (msg) {
console.log('message from php: ' + msg);
})
});
I can see the logs for Client connected and Client disconnected but no messages. Can you see any obvious mistake?
Thank you
The text was updated successfully, but these errors were encountered: