-
Notifications
You must be signed in to change notification settings - Fork 95
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
websocket and client on same server - possible bug #50
Comments
Hi Den, This sound interesting and as far as I know, could be either code issue or some library bug. Best thing to do is to share your code, it will allow me and anyone who wish to help recreate the problem and try and solve it. If you rather not share your code, try creating a smaller version of it such that it don't reveal anything you don't wish to share. Best wishes, |
Hi Gil thanks for the reply .. Kind regards Den |
Hi Gil Ok as a start let's go with the following : Below is the basic websockets server (slightly modified , but should make no difference right ?) Also included is a simple websocket client test html page (attached as TXT , just rename it to HTML ..it's a work in progress at the moment ..perhaps you like it ? Let me know :-) Load up your websockets server onto and ESP8266 and then open the websockets test page in a browser from your client and test. I'm finding the websocket server with the example code on is crashing ( usually stops responding when connect and send is chosen) ..can you please confirm beahvior ? The same code crashdumps the ESP8266 its on when I send it code from another ESP acting as a client. (Server labelled as B in diagram in previous message in this thread) As an aside question is there any way of displaying which IP (and/or hostname) each client is coming in from ? I will post server and client combined code in the next posting ( battling to keep eyes open now ;-0) Kind regards CODE being used to send from B
SKETCH on C (acting as a websocket server)
|
Hi @denden4444 I will try to reproduce the bug this weekend. I think you should provide more code from sketch B. I see no client handling, which is the most important part. When you say the code crashdumps the esp8266, what do you mean? What kind of crash is it (what is logged to serial)? |
The code on server C is the basic server example (see above) Kind regards Den ********** PLEASE IGNORE THIS SPECIFIC REPLY .. MIRACULOUSLY C IS WORKING FINE NOW !! Problem reported with B still exists -- closes client A connection after making a connection to C |
Hi @denden4444 , It seems like your B code tries to re-use the same WebsocketsClient instance twice. That won't work. Every time you call Also, notice that when you are doing Gil. |
Hi Gil
I look forward to your reply. Kind regards Den |
Hi Gil .. Problem solved with the above ;-) , I therefore don't think there's any bug in the code .. perhaps you could confirm ? I will try setup something simpler for you to test with and post here over the weekend. So does this mean I could in fact run multiple instances of the websockets server on same chip as well ?
Kind regards Den |
Hi Gil Just need to clarify ...
2..
Currently the code is working with 1. but I suspect 2 is most correct since your standalone server only uses this to start :
and later on in the main loop uses the following:
I'd love to hear your thoughts and/or guidance. Kind regards Den |
Hi @denden4444, First thing is you should understand what those lines do.. Do you need 2 clients or one? Depending on what you are doing and how you write your code. If you can start and finish using the client from the server within one function, you don't need to declare it globally. In my server example, for example, I do something small with the client connection and then close it immediately. If you want to keep the connection alive, you will need a global variable to hold to client. Gil. |
HI Gil Thanks for the reply. In terms of whats needed .. as the previous diagram shows. At Server B Server C Could you kindly elaborate/expand on the below statement :
The above can happen between B and C in the diagram.
The above happens between A and B in the diagram: I hope that clears it up further. Kind regards Den |
So this is a usage question rather than a bug. And the question seems to have more to do with general coding concepts than with the library itself, so I don't think it belongs here. Contact me privately. |
Hi Gil
Hope all's well with you.
As you may recall I have been testing your websockets on the ESP8266 and the tests have been good so far.
I'm hoping you could possibly identify/clarify some strange anomalies.
I am running both client and server on the same ESP8266.
Please refer to this image:
![websockets client and server in one](https://user-images.githubusercontent.com/34808437/67994594-a953c980-fc4e-11e9-93fd-b0ed2c1ccaca.png)
A is a client (web browser) and needs to stay connected all the time until A decides it wants to disconnect
B is the ESP running both client and server.
When B receives a certain message , B fires up the websocket client portion and as w ebsocket client establishes a connection with C (C is running as a websockets server)
The above happen successfully (YAY ;-)) BUT
after B closes the connection (client disconnect) with C , the connection of A to B is lost. :-(
I have tried to set B not to close the connection to C ( no disconnect) but the same behavior occurs between A and B.
So I end up having to refresh the browser at A which re-establishes the connection from A to B.
Could you possibly shed some light as to how or where I could check and fix this ?
I'm not sure if this your software that may be causing the following :
Sometimes base on the problem in point 1. above , I am unable to re-establish a browser and/or websocket connection from A to B .
Its seems like B just stops servicing browser and/or websocket requests and sometimes a ping even though the serial console is still responding quite fine.
Any thoughts ?
Kind regards
Den
The text was updated successfully, but these errors were encountered: