Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit not working on android #32

Open
Kouznetsov opened this issue Nov 7, 2022 · 6 comments
Open

Emit not working on android #32

Kouznetsov opened this issue Nov 7, 2022 · 6 comments

Comments

@Kouznetsov
Copy link

The socket.Emit() function works correctly on the Editor.
My android device receives the messages as expected, but when Emitting from android, nothing shows on the server or elsewhere. The code is the same on the Editor and the Android device.

@itisnajim
Copy link
Owner

duplicated ?
#12

@Kouznetsov
Copy link
Author

I don't think so, the server is working fine. The same thing happens on iOS. Login and message receiving are working but nothing gets emitted. No error is raised either.
The other thread suggests that android might be missing the internet permission but my game already uses internet without problem.

It might be related to the fact that my server is not running on https. The thing that's weird is that it still connects and receives messages. I expected everything to fail directly.

@itisnajim
Copy link
Owner

itisnajim commented Nov 8, 2022

try these:
doghappy/socket.io-client-csharp#134
doghappy/socket.io-client-csharp#129
doghappy/socket.io-client-csharp#120
doghappy/socket.io-client-csharp#113
doghappy/socket.io-client-csharp#24
doghappy/socket.io-client-csharp#5

and try to emit an empty event, something like:
socket.Emit("eventName");
or different (player )build settings!

also build on pc/mac and see if this is only on android !?
sometimes restarting the app can fix this if you are working on localhost or in a local network.

@itisnajim itisnajim pinned this issue Nov 8, 2022
@itisnajim
Copy link
Owner

try updating unity
see #36

@timbotimbo
Copy link

For me this was caused by IL2CPP breaking the JSON serializer that is used by default.
Simply switching to the Newtonsoft option (that's already included) makes Emit work on Android and iOS.

using SocketIOClient.Newtonsoft.Json;

socket = new SocketIOUnity( ... );
socket.JsonSerializer = new NewtonsoftJsonSerializer();

@wstevenrodriguez
Copy link

For me this was caused by IL2CPP breaking the JSON serializer that is used by default. Simply switching to the Newtonsoft option (that's already included) makes Emit work on Android and iOS.

using SocketIOClient.Newtonsoft.Json;

socket = new SocketIOUnity( ... );
socket.JsonSerializer = new NewtonsoftJsonSerializer();

it's works thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants