washo4evr / Socket.io-v1.x-Library

Socket.io Library for Arduino
108 stars 58 forks source link

Socket.emit #37

Closed vlp-github closed 7 years ago

vlp-github commented 7 years ago

Hi, Really nice lib !! Just a quick question, on my socket.io server or client I use:

In my ESP code, I have used: client.sendJSON("messageType","hello"); but my server doesn't receive my "hello"

any tips ?

Thanks !

washo4evr commented 7 years ago

Hi,

thanks for using this library.

Did you try running the example provided with the lib? is it working?

I remember my firewall was messing with my experiments back then, maybe you can also check that

Let me know

vlp-github commented 7 years ago

Thanks for the answer. Yes, my ESP can reach my server. On the Serial port I have all the log that confirm it:

Connexion établie
Handshake établie
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Content-Length: 100
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: Arduino
Set-Cookie: io=PJn_Tr53c67VCPJ1AAAL; Path=/; HttpOnly
Date: Thu, 30 Mar 2017 20:00:05 GMT
Connection: keep-alive

97:0{"sid":"PJn_Tr53c67VCPJ1AAAL","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000} 
Connected. SID=PJn_Tr53c67VCPJ1AAAL
Connecting via Websocket
Websocket send
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: xcTAOQ88pRoo1GQAtE2Roi8I3ls=

And on my Server side I can confirm it as well because once someone get connected with the server I send a message to the client.

io.sockets.on('connection', function (socket) {

    socket.broadcast.emit('message', 'ESP_live');

And indeed, I can see the message ESP_Live on my client page.

However, one I am connected, I don't know how the ESP can send a message.

In my client page I use: socket.emit('messageType', 'hello');

And if I write: client.sendJSON("message","ON"); in the ESP code, nothing happen on my server... no message are received.

Thanks for your help !

vlp

vlp-github commented 7 years ago

Solved ! I need to improve my json skills :+1: