-
Notifications
You must be signed in to change notification settings - Fork 2
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
.NET 4.x GS WebSocket Issue #4
Comments
|
As this ticket has been open for 4 months now, it doesn't look like it's going to happen. @gamesparks, if you are reading this, it would do the community a great favor for one more update to at least make things scalable ... we sort of need a headstart. This isn't just updating a small bug~ No one here is knowledgeable enough for a websocket replacement. We're pretty talented folks, but ... this is a bit beyond us. Here are some alternatives (that support Windows 7, as native Microsoft WebSocket does not): https://archive.codeplex.com/?p=websocket4net |
I changed out the websocket to be the same for all platforms - mostly because I didn't care about some like switch or xbox. I used this websocket as it works on all my target platforms: https://github.com/endel/NativeWebSocket I no longer get timeouts on iOS after changing the websocket out. |
Sounds promising! Do you mean you just swapped out a DLL, or required code? I have no idea where to even begin for this. Any chance of a pull request and/or mini guide, @jconradi ? Also, does that lib support Win7, too? When I hear "native" and websocket together, sometimes I'm susp since Microsoft's native version doesn't support it. |
I stumbled upon this issue as well, and based on the My custom websocket implementation can be found here To use it, modify GameSparksWebSocket socket = new GameSparksWebSocket(); to socket = new CustomGamesparksSocket(); Add protected override void Update()
{
if (socket != null && socket.State == GameSparksWebSocketState.Open)
socket.DispatchMessageQueue();
base.Update();
} I've tested this solution on Android (Mono and IL2CPP) and iOS. This may not be a perfect solution to include into the community SDK repository, but hopefully it can help others who are stuck with this problem. |
Nice, @zarlin ! I read that custom implementations should work with Win7, too (but then again, anything with the word "Native" in it combined with "Socket" often leaves out Win7 support; will need to test). Seems like the CustomGamesparksSocket.cs doesn't know where NativeWebSocket is - anyone else experiencing this? I tried I feel like I'm missing something right in front of me. |
https://github.com/sta/websocket-sharp feels promising if this doesn't work with Win7 |
Thanks to your template, @zarlin , I almost got WebSocketSharp working, but 10 errors away: Could use some help ~
|
Update: Errs are gone (thx skoolbusdriver). Ignore above, just drop this: Download (WIP 1)Swapped Native WebSocket (lacking Win7 support) with websocket-sharp using @zarlin 's template (WIP): Notes/Leads
EditUnfortunately, that's about all the time I have for trial+error. We're REALLYYY close .... just need someone more knowledgeable on this topic to add the finishing touches (not sure why this isn't firing - probably some rookie mistake). |
Got it working!Use this .zip below to swap out Native socket with WebSocketSharp with alleged win7 support. Download(Nov 28, 2020 EDIT: v3) TODO
|
So, this is it! Resolved. At least, this issue. We could open a new bug for fixing this from src instead of ghetto swap: I'm not quite sure how src auto-gen's this stuff ... can anyone throw this in src? We could also use a "release" version, if someone wants to make an empty project with GS already thrown in. |
Offering BountyOffering 💸 $500 AWS coupon code to anyone that can figure out how to do all of the following:
|
@dylanh724 I believe one thing that was missed was ping/pong requests. Refer to the GameSparksWebSocket.cs implementation. It enabled auto pinging at an interval of 30 seconds. In my testing, without this pinging the server sends a Close opcode after a period of inactivity which causes the client to close the connection on Stadia. WebSocketSharp has an IsAlive property you can check which sends a ping and waits for a pong. This is a blocking call however. In my own code I just created a Timer that calls the IsAlive getter every 30 seconds and this has prevented disconnects for us. Edit: |
Thanks @chorakm - after calling Ping(), how do you tell GS there's a heartbeat, assuming IsAlive may still be true? Or do I just "re" set IsAlive back to true and it will trigger things in the background? If false, do nothing (GS will handle d/c)? For the timer, do you use InvokeRepeating() or Update()? Low priority, but any chance for a lazy-man's snippet if you happen to be staring at it? 👍 |
Hey @dylanh-pt no problem. So to clarify, IsAlive is a computed property that calls Ping(). Ping returns true or false. It sends a Ping OpCode, and blocks to wait for a Pong opcode from the server. Because this is a blocking call, I did something similar to what's going on in WebSocket4Net where they create a Timer to send a ping on an interval in a thread pool. GSConnection doesn't seem to care whats going on underneath, just that the socket is open and ready. Sending the ping every 30 seconds seemed to prevent the GameSparks backend from sending the Close opcode, which I assume they do because they can't tell if the client on the other side of the TCP connection is still there, so they just terminate the connection. I'm uncertain as to why this is only occurring on Stadia however. May be something specific to Linux Here is what I did in CustomGameSparksSocket.cs:
|
Thanks for that! When I get to my own time, I'll toss up a new zip and relook over that pull request from the other guy. With his pull request, we can see where to edit and possibly toss this in, too. |
GS-WebSocketSharp-Nov28_2020-Final3.zip |
Ever get an extremely-vague{ "error" : "timeout" }
(or something like this)? Didn't get it before?^ EDIT: This is deducted to be a 100% unrelated issue, now reposted here: #7
Well, it seems that this is caused by .NET 4.x issues -- specifically with WebSocket (dll). Although rare, this can cause serious damage to the player experience since it's almost impossible to handle all situations containing this. It's also hard to figure out where the timeout happened since absolutely no useful information is contained within this error.
Apparently, we can swap to a community version of WebSocket "with a few lines of code". However, I'm unfamiliar with this. Anyone wanna experiment with this?
Somewhat related
Fixing this bug would also likely resolve this issue: #3
Important Note
Native WebSocket does NOT include support for Windows 7 (Only Win8+). Any "Native" port will not work for us. We need a custom WebSocket implementation only.
Options
It is crucial that there is Windows 7 support included whatever we port to. We must use a non-native, open source edition. There are
several3 options:The text was updated successfully, but these errors were encountered: