colyseus / colyseus-defold

⚔ Colyseus SDK for Defold Engine
https://docs.colyseus.io/getting-started/defold-client/
MIT License
60 stars 10 forks source link

Leave code = 0 after Admob rewarded video showing #54

Closed baochungit closed 7 months ago

baochungit commented 7 months ago

Once again, I'm not sure if this issue is from Colyseus Defold or Websocket extension. After the admob rewarded video showed and closed, the room fired "leave" event with message.code = 0. The video is just an admob testing, just around 7 seconds.

Please help to check. Thanks a lot!

baochungit commented 7 months ago

I tried adding

[websocket]
socket_timeout = 60000000

to game.project but it doesn't help..

baochungit commented 7 months ago

I just found that the connection will be closed after around 5-7 seconds when the app (or the MainActivity) goes inactive (share popup displayed, admob rewarded video shown, ...) Checked on Android, my Galaxy Note 10 plus

baochungit commented 7 months ago

It seems this issue is mainly related to Websocket extension.

2024-02-11 13:01:14.038 25626-12477/com.chungxa.kyhoang I/FA-Ads: Application backgrounded at: timestamp_millis: 1707631272034
2024-02-11 13:01:23.158 977-4271/? V/WindowManager: Changing focus from Window{f2c706f u0 android/com.android.internal.app.ChooserActivity} to Window{6bdfc0c u0 com.chungxa.kyhoang/com.dynamo.android.DefoldActivity} 
2024-02-11 13:01:23.267 25626-12478/com.chungxa.kyhoang V/glfw-android: handleCommand (main thread): APP_CMD_RESUME
2024-02-11 13:01:23.268 4593-26884/? I/[AirCmd]_RemoteSpenMainController: hasGeneralAction : packageName is com.chungxa.kyhoang, activityName is com.dynamo.android.DefoldActivity, hasActions is false
2024-02-11 13:01:23.268 25626-12478/com.chungxa.kyhoang V/glfw-android: handleCommand (main thread): APP_CMD_GAINED_FOCUS
2024-02-11 13:01:23.268 25626-12478/com.chungxa.kyhoang E/defold: ERROR:WEBSOCKET: Websocket poll error: WSLAY_ERR_CALLBACK_FAILURE
2024-02-11 13:01:23.276 25626-12478/com.chungxa.kyhoang E/defold: ERROR:WEBSOCKET: Failed to setup callback
2024-02-11 13:01:23.283 25626-12478/com.chungxa.kyhoang D/defold: DEBUG:SCRIPT: [Colyseus] websocket error

Is there any way to advoid this issue? I have a react native app with websocket, colyseus.js still working fine when app goes inactive state for pretty long time so I guess we can also do it with Defold..

git2013vb commented 7 months ago

Hello, same problem here. I start to learn how to use it and when I iconize my client (I want to see my console) the connection drop. It will be nice to have some documentation for these "hidden" cases ;) Thanks. Nice work.

~ I support Creative Society https://creativesociety.com/ ~

baochungit commented 7 months ago

Unfortunally, there's no way to avoid it at the moment. Since it's not the issue of Colyseus, I will close this issue.

FYI, you guy can do reconnecting when got leave message, though it's quite inconvenient

baochungit commented 4 months ago

FYI, although this issue due to the unresponsive client side but it can be fixed at server side by increasing options.pingInterval value.