You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think everyone here knows that ESPAsyncWebServer (or at least its origin fork) is a disaster in terms of thread safety. PsychicHttp is reported to be much better, which is great! But it's important for users to understand threading semantics to be able to write safe code using it...
The README has similar notes as ESPAsyncWebServer does, without clarifying too much: "PsychicHttp is a fully asynchronous server and as such does not run on the loop thread. You should not use yield or delay or any function that uses them inside the callbacks."
It would be good (necessary, even) to know the following
Q: What is the thread context user callbacks are invoked on?
I think: the HTTP server thread, which means if that thread touches any of the same data loop() does, it MUST USE SYNCHRONIZATION, which basically nobody is doing?
Q: What threads can methods on various PsychicHttp type objects be called FROM?
The PsychicHttpServer object should ONLY be accessed from the setup() / loop() thread??
What if you want to access it from a request handler?? What's safe and what's not?
The PsychicRequest object should ONLY be accessed from the request handler
Similarly with PsychicWebSocketClient, ONLY access it from the event handler
But you can save the socket (an int) somewhere, and use getClient() later
where is it safe to call getClient() from??
how long is it safe to use the PsychicWebSocketClient you get back from that??
Q: What happens if you DO delay, or yield, or do long-running computation in a callback?
Q: What happens if you're sending lots of data, and the receiver is being slow (or goes offline entirely)?
Does this just stuff up the server thread indefinitely until some timeout?
Q: What happens if a client dribbles out the request headers and stuff?
Again, does this just stuff up the server thread indefinitely?
The text was updated successfully, but these errors were encountered:
I think everyone here knows that ESPAsyncWebServer (or at least its origin fork) is a disaster in terms of thread safety. PsychicHttp is reported to be much better, which is great! But it's important for users to understand threading semantics to be able to write safe code using it...
The README has similar notes as ESPAsyncWebServer does, without clarifying too much: "PsychicHttp is a fully asynchronous server and as such does not run on the loop thread. You should not use yield or delay or any function that uses them inside the callbacks."
It would be good (necessary, even) to know the following
loop()
does, it MUST USE SYNCHRONIZATION, which basically nobody is doing?PsychicHttpServer
object should ONLY be accessed from thesetup()
/loop()
thread??PsychicRequest
object should ONLY be accessed from the request handlerPsychicWebSocketClient
, ONLY access it from the event handlergetClient()
latergetClient()
from??PsychicWebSocketClient
you get back from that??The text was updated successfully, but these errors were encountered: