-
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
webSockets client and server on same ESP ? #35
Comments
Hi,
Thanks! This was my exact intent when creating this library.
I'd love to help more, good luck! |
Hi Gil Thanks a million for the response .. it is truly mega appreciated ;-)
YAY ;-) .. I have been on a mission since last year trying to find a websockects library or implementation that is more controllable and versatile without compromising speed and program space. I will load each of these on an ESP8266 and then test client and server , once both are working I will put both on same and ping you back with feedback. Thanks for the 'love to help more'too, and if it's ok with you I'm sure I'll be sending more questions as the days go by and I'm happy to test or help you as well with the project. Kind regards Den |
For sure, it's a pleasure. I can't promise maximum efficiency. Iv'e worked hard for this library to be easy to use and user-friendly, but that means I do make some compromises regarding efficiency. That being said, I did try to optimize most operations, so hopefully this library will be good enough for you needs! Have a great day and good luck, (I'm keeping this issue open in case you will have any follow-ups) |
Hi Gil Just a quick update .. I have success so far with both server and client on same .. still need to perform further testing but its working so far. Could it not be more server related in terms of the names e.g : It's probably a silly question but it's going to be a little difficult to follow the code in my instance where I'm running server and client on same ESP8266. I look forward to your reply as always. Den |
Hi Den, There is documentation and example for almost everything you ask about in the Wiki. Also, lets keep all discussion here unless it is a bug report or issue with the library. Gil. |
Hi Gil Thanks for the replies, much appreciated. Is there a Q&A forum ? I had read the multiple clients section as well as the poll options.
I am able to make a websocket connection from PC to the server(ESP) but no sent data appears ..did i miss something ? or mess seomthing up ? Thanks again for the replies and I will keep questions limited to this thread and will double check documentation first. |
Hi Den, The docs are indeed for TinyWebsockets which is the source project for this project. The two code-bases are the same except for few files and file-structure differences between an Arduino library and a CMake library. Everything that is written there is applicable here as well.
Nope, there is not. I never had so many usage questions to be honest. I don't know if a forum is a good idea - currently I'm the only one here maintaining and answering issues so I won't have the time to manage a forum as well. Because you set a callback, the client need to sometimes check and see if there is anything new (new messages, new events). In order for the client to check those stuff, you must call if (server.poll()) {
client = server.accept();
// Do other stuff with the client
}
if (client.available()) {
client.poll();
} So at the end of each loop, if there is a client connected it will check for changes, messages, etc. |
Hi again Gil I managed to get the client and server working on same ESP. I have an issue now where the websockets work but I cannot load any html webpage from the ESP SPIFFS using a web browser when the websockets code is in the main loop. If i remove the websockets code from the main loop and upload the sketch then the web pages load correctly.
Am I setting up the websockets incorrectly ? I hope you can shed some light here. If you need extra info please let me know. Kind regards |
Hi Den, Notice that the code is blocked until there is a client to accept. Meaning until there is a WS client that tries to connect, the loop won't re-start and I'm not sure how the webserver code works, but I assume the method should be called frequently. In order to only accept a client when there is actually a client trying to connect, use I hope this will solve your issue. |
Hey Gil Thanks for the reply ;-), hope alls well with you.
Actually I don't notice that because i have other functions running in void() loop which run and are running in each iteration of the loop whether there is a client or not ;-( Would you mind indicating where I should place server.poll , I tried it a few nights ago and was not successfull (I couldn't get a websocket connection) I'm happy to run the tests with server.poll in place I'm just really unsure of exactly where to put it in and didn't notice an example it in the sketch examples but did see it used in some examples in the issues and the api pages for tinywebsockets. Thanks again Gil . Den |
Add a serial print before |
will do that now |
Gil |
I think I finally have it working .. ;-) YAY Thank you kindly |
Hi Den! I'm glad it's working. The link to your comment seems to be broken, can you link it again? what So, if you call
Best wishes, |
Hi Den! Seems like this issue is inactive for now, I hope it means that everything is working as expected 😄 I'm closing it for now, if you have any other usage question feel free to open a new issue or send me an email. Also, I'm considering some sort of chat channel for support. Maybe on discord or slack. I'll just place that sentence here and see if there is anyone interested in that. Best wishes, |
Hello Gil
This looks like an awesome alternative to other libraries, and I'm quite excited to try it ;-)
I just need to know the following please :
I need to have the server and client on the same ESP. is this possible and if so could you kindly explain how or provide an example ?
Please see attached pic for reference.
I would like to enable to disable the connection(client and/or server) when desired/required, independently of eachother.
For example (pseudo code) :
client enable
do something
client disable
and same as above for server
Are you able to call (and control - disable/enable) client and/or server from anywhere other than the main loop ?
Really looking forward to your reply
Kind regards
Den
The text was updated successfully, but these errors were encountered: