question

Jack Hines avatar image
Jack Hines asked

Multiplayer 2 Websocket Support

Hi,

I am building a webgl based multiplayer game which I am creating via Unity. I am working on some small tests to get the fundamentals in place.

I have got mirror up and running between server/webgl on local. I want to use the playfab multiplayer 2 system and have got the basic telepathy example working via docker etc.

However I cannot get websocket working. My understanding is that this is a functionality built on top of TCP so I would assume that it would be possible for the system to work given the correct setup?

Would this be possible?

Thanks

Jack

support
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jack Hines avatar image
Jack Hines answered

@Citrus Yan I was implementing the transport from the folder as you have said. I have done some digging and modified the Websocket Code in Mirror. It turns out that the Websocket code was using IPv6. However with the telepathy code it was using IPv4. Therefore I changed the websocket to IPv4 and this has worked. I can now connect to the local server correctly. I am not sure however what implications this would have for web socket and am doing some research. Do you know anything about this? Thanks

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

So is this the code that you are referring to?https://github.com/PlayFab/gsdkSamples/blob/ce30d7abb7ef1687c78296ff7a7b2780a67278ee/UnityMirror/UnityClient/Assets/Mirror/Runtime/Transport/Websocket/Ninja.WebSockets/WebSocketClientFactory.cs#L89

And, as I understand it, theoretically, it's OK to change Websocket, which is on the Application layer (TCP/IP model), to IPv4 since it's built on top of TCP, which resides on the Transport layer and hides the underlying IP protocol to upper layers.

0 Likes 0 ·
tobias-hoerl avatar image tobias-hoerl commented ·

Hello Jack Hines, I might encounter the same problem you solved here. Could you elaborate a little how you modified the code to work with IPv4? I tried just changing the constructor for the TcpClient so far, but without any success (protocol not supported errors in the project).

0 Likes 0 ·
Citrus Yan avatar image
Citrus Yan answered

One quick question: how did you implement your server? Was it in C#, Java, or C++?

6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jack Hines avatar image Jack Hines commented ·

In C# unity mirror and following this tutorial https://github.com/PlayFab/gsdkSamples/blob/master/UnityMirror/README.md

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Jack Hines commented ·

I do see Unity Mirror implements Websocket in this doc: Mirror.Websocket, however, the project for this tutorial doesn't implement this feature, hence you may need to implement it by yourself. Anyway, I believe it's possible for you to implement Websockets using Unity Mirror, may I know the troubles you are facing when trying to get websocket working?

0 Likes 0 ·
Jack Hines avatar image Jack Hines Citrus Yan commented ·

I have got the server running on port 7777 in a docker module as per the tutorial, with this mapped to the local port 56100. On Telepathy transport if I set the client to 56100 local port it connects to the running local docker server. However if I change the setup to Websocket and run on the same port (7777 docker server and 56100 local) the client will not connect and keeps returning "SocketException: The requested address is not valid in its context." This indicates that the client cannot find the local docker module (I have tried setting the client to port 7777 too and this does not work!)

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.