Hi. I am having some issues with sockets disconnecting due to a timeout.
I have 3 different programs talking to each other using sockets. The Command Center (CC) sends messages to the Modal Manager (MM). The Modal Manger can send messages to the VR App. I have this working to the point where the Command Center (running on my PC) can send a message to the Modal Manager (running on my Android device), to launch another app. I can then send a message from the Command Center to the Modal Manages asking it to kill the app it launched, and that works fine.
Now I wanted to add a response from the Modal Manger to the Command Center. Basically, I just want the Command Center to ask the Modal Manger to report the temperature. I thought that this would be simple enough, but when the Modal Manger receive the message from the Command Center, it reports that there is a timeout on the socket.
One interesting thing is that if I run both the Modal Manager and the Command Center on my PC in the editor, everything seems to work fine. I just change the IP addresses of both to 127.0.0.1
So it seems like I am passing messages in one direction correctly, but my response causes the issue.
The relevant code is attached.
This is my log from ADB Logcat
04-04 14:53:18.131 24916-24931/? I/Unity: Creating NetworkCommandManger thread
04-04 14:53:23.301 24916-24931/? I/Unity: localPort is 9001
04-04 14:53:23.301 24916-24931/? I/Unity: remotePort is 9000
04-04 14:53:23.301 24916-24931/? I/Unity: name is CC Socket
04-04 14:53:23.337 24916-24931/? I/Unity: CC Socket: Socket Open. socketId is: 0
04-04 14:53:23.338 24916-24931/? I/Unity: CC Socket: Connected. connectionId: 1
04-04 14:53:23.338 24916-24931/? I/Unity: localPort is 8888
04-04 14:53:23.338 24916-24931/? I/Unity: remotePort is 8889
04-04 14:53:23.338 24916-24931/? I/Unity: name is VR App Socket
04-04 14:53:23.340 24916-24931/? I/Unity: VR App Socket: Socket Open. socketId is: 1
04-04 14:53:23.340 24916-24931/? I/Unity: VR App Socket: Connected. connectionId: 1
04-04 14:53:24.860 24916-24973/? I/Unity: CC Socket: Incoming connection event received
04-04 14:53:29.381 24916-24973/? I/Unity: CC Socket: Incoming message event received: {“command”:“ModalVR.GetTemp”}
04-04 14:53:29.384 24916-24973/? I/Unity: ParseDataEvent Received: {“command”:“ModalVR.GetTemp”}
04-04 14:53:29.433 24916-24973/? I/Unity: WrongConnection: CC Socket: SocketConnection.SendMessageCommon
04-04 14:53:41.476 24916-24973/? I/Unity: Timeout: CC Socket: SocketConnection.Receive
04-04 14:53:41.478 24916-24973/? I/Unity: CC Socket: Remote client event disconnected
04-04 14:53:41.478 24916-24973/? I/Unity: Timeout: VR App Socket: SocketConnection.Receive
04-04 14:53:41.478 24916-24973/? I/Unity: VR App Socket: Remote client event disconnected
Thanks in advance for any help.
John Lawrie
3019997–225575–ModalManager.cs (4.91 KB)
3019997–225576–NetworkCommandManager.cs (3.15 KB)
3019997–225577–SocketManager.cs (1.89 KB)
3019997–225578–SocketConnection.cs (3.6 KB)
3019997–225579–CommandManager.cs (3.2 KB)