SocketIOUnity icon indicating copy to clipboard operation
SocketIOUnity copied to clipboard

Socket emit not passing data for some seconds

Open devalvitec opened this issue 2 years ago • 3 comments

Hi ,

I am in the middle of game development and my game emits data for 30-40 seconds and then it pauses for some reason for almost 5-10 seconds and then whatever data I have emitted in those 5-10 seconds it's received all together in one go.

what might be the reason for that,

We have checked in the server with log and timestamp they says that Unity's socket call is not receiving to the server and as they receive all call at the same time server provide a response as one go.

any suggestion here on what might be the problem?

devalvitec avatar Oct 19 '23 02:10 devalvitec

see with https://github.com/doghappy/socket.io-client-csharp

itisnajim avatar Oct 20 '23 17:10 itisnajim

I spent a couple of hours not understanding why I had similar problems and it boiled down to the fact that something silences all exceptions in socket.On() calls and furthermore you cannot reach the main thread objects through it - so you cant trigger anything in Unity directly from within the socket.On() function handler ! You have to store your response in a variable which you then read from e.g. OnUpdate to actually handle the message.

64jcl avatar Nov 30 '23 13:11 64jcl

I spent a couple of hours not understanding why I had similar problems and it boiled down to the fact that something silences all exceptions in socket.On() calls and furthermore you cannot reach the main thread objects through it - so you cant trigger anything in Unity directly from within the socket.On() function handler ! You have to store your response in a variable which you then read from e.g. OnUpdate to actually handle the message.

u have to use socket.OnUnityThread instead of socket.On

itisnajim avatar Nov 30 '23 14:11 itisnajim