Can't receive message before sending
My server emits a message when a client connects, "authenticate". The client should respond. But with socketIO-client, if I connect and then wait, I never get the "authenticate" message even though the server sent it as usual (I checked with wireshark). I have to send something first from the client, and then send "authenticate" from the server after the server receives that first message from the client.
Is there something I should do to fix this on my side?
class MyNamespace(LoggingNamespace):
def on_authenticate(self, args):
print("Got authenticate message!")
with SocketIO('127.0.0.1', 8000, MyNamespace) as socketIO:
# After we connect, server will send us "authenticate"
socketIO.wait()
I don't think there is a such method ("on_authenticate"). If you wanna catch "authenticate" message, you would need to listen on it, like on("authenticate", callback)
Hi @e-tang,
Is there any way to call on("authenticate", callback) before connection is established? Otherwise we have a race, right?
Hi @bufistov
I am not quite sure what you meant here, but how could you start authenticating without establishing a connection first?
You can start the authentication process after the "on _connect" is called.
Or You can have a look my implementation tyo-mq client for python in a pub/sub way.