morrissinger / ESP8266-Websocket

A websocket library for the ESP-8266.
305 stars 118 forks source link

handshake error #2

Closed jc19000 closed 9 years ago

jc19000 commented 9 years ago

Dear morrissinger,

I have some issue with yout websocket client part. I try with example as you defined and i have the following message on the serial port:

Connecting to NUMERICABLE-A8B3 ......... WiFi connected IP address: 192.168.0.22 Connection failed.

ctx: cont sp: 3ffea780 end: 3ffea960 offset: 01b0

stack>>> 3ffea930: 3ffe8f88 1600a8c0 00000000 00000000 3ffea940: 3fffdc20 00000000 3ffea984 40201863 3ffea950: 00000000 00000000 3ffe9940 40100db4 ▒▒▒▒L▒<1▒▒▒

I modify the different information and try to connect to my own websocket server and i have the following message: Connecting to NUMERICABLE-A8B3 ........... WiFi connected IP address: 192.168.0.22 Connected Client connected Sending websocket upgrade headers Analyzing response headers Invalid ANALYSE REQUEST Terminating socket Handshake failed.

I also test my server with the websocket echo online client and it worked. But with your client it does not work It seems that the client nerver received data from the handshake.

Did you have a client example that works?

morrissinger commented 9 years ago

No, unfortunately this is a work-in-progress that I have had to very much back-burner due to some other priorities.

frippe75 commented 9 years ago

I'm having the same issue as of yesterday. Found some simple errors I will be sending you a pull request later on. As to the handshake issue.

Looking at the handshake part its clearly stated that improvements to both string extraction and the string compare part of upgrade requests "Upgrade: WebSocket" that sets the foundupgrade variable is needed.

I used firefox to trace the upgrade request and firefox is falling into the category of "Upgrade: websocket" which is covered by the first elseif. But in my case I think that socket_client->read() fails to get any data because I enable debugging and the line "Got Line:" never appeared over serial. So two options. Either no data or no newline. Will look more into this later this weekend.

morrissinger commented 9 years ago

If you do a PR, I would be excited and thankful to merge it.

jc19000 commented 9 years ago

I advance a bit on the problem, i change of library i use the one advise in the esp arduino reference: https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/doc/reference.md#other-libraries-not-included-with-the-ide

which is https://github.com/Links2004/arduinoWebSockets

and i have the same problem with my qt websocket server but when i use on other server https://github.com/dpallot/simple-websocket-server it seems to work.

frippe75 commented 9 years ago

Ok, I found a problem in my code.. I THINK you might be having the same. I have not been able to try it but since you were also testing against (I suspect) uri: "wss://echo.websocket.org" ... I made the simple mistake of keeping the wss:// part which resolves to https instead of http for uri starting with ws://

It might be that simple....

Thats why I'm not seeing any data I suspect.

morrissinger commented 9 years ago

I did two tests. In one, I ran it against a Docker container running a Websocket server. This one worked. I then tested against echo.websocket.org, which did not work. Thanks to your discovery, now I know why.

jc19000 commented 9 years ago

Ok so i just test with your library and my python server and it's work. The issue is not on you but on the Qt side... Sorry for the mistake. I also hope that you can cast a glance at the official library that i found easier to use: https://github.com/dpallot/simple-websocket-server