0

I have a Django Server work as 2 role: Socket Server and Socket Client.

1/ As a Socket Server, it work on local side, so some clients in same network can connect and receive event.

2/ As a Socket Client, it will connect (using Socket) to another Remote Server to receive events and forward that events to all local clients

But when Socket Client receive events then emit to local clients by Socket Server, nothing happen (local clients can't receive that events).

It seem Socket Server and Client can't working together. Here is some sample of my code:

// Receive event from Remote Server
self.__client__.on("event_msg", self.onEvent)

// Forward event to local Clients
def onEvent(self, package):
    self.__socketServer__.emitEvent(event="event_msg", data=package, to=None, room="123")

The __socketServer__ is just an instance of SocketServer class, and it can work if just simple send/receive message in local network (not put in socket client event)

I'm using python-socketio for both Server+Client

EmBeCoRau
  • 327
  • 1
  • 4
  • 14
  • The server and the client are completely independent, so they should not interfere with each other. Can you emit from your server when there is no client? Or in other words, are you sure the problem with your server occurs because you also have a client, or can it be another unrelated issue? – Miguel Grinberg Nov 25 '20 at 22:21
  • Yes I'm sure I can emit from my server in simple case send/receive in local. In the opposite way, I put my client code into server event listener code, and forward it to the remote server, it can work well in this case – EmBeCoRau Nov 26 '20 at 01:27

0 Answers0