I am making a H5 game basing on the WebGL. I set up the WebSocket server on the extend app sharing the same Service URL. It works fine locally with the ws protocol. But when I deployed it to the cloud and change it to wss, I got an error like:
wscat -c wss://■■■■■.prod.gamingservices.accelbyte.io/ext-■■■■■-ExtendLogicServer/wslogic
error: Unexpected server response: 403
I wrote some test code and confirmed that the request did not reach the extend go gateway.
So I need your help to identify the reason.
Hi @user18 , I’m Eric, an SE from the Extend team.
This might be due to the missing of the bearer token in the auth header due to PLUGIN_GRPC_SERVER_AUTH_ENABLED being turned on, since at the AB hosted environment, environment variable PLUGIN_GRPC_SERVER_AUTH_ENABLED is by default set to true for security reason if not specified (saw that you don’t have it set for your app on the Admin Portal). Which means the Bearer token will have to be attached to the header via the wscat command, like this:
This also coincides with the 403 error meaning forbidden.
As a sanity test, could you temporarily set PLUGIN_GRPC_SERVER_AUTH_ENABLED=false and retry with what you are already doing? If that works, follow up by either removing this env var or setting it to true, and attach a Bearer token as shown above?
I wrote some test code and confirmed that the request did not reach the extend go gateway.
On the other hand, just to make sure we are aligned, could you elaborate what you did exactly?
Did you mention that you are able to create websocket service using Extend Service Extension and it works locally? It is interesting. Could you elaborate more on this?
Hi @user18
I’m Vincent, Extend Product Manager.
Currently, Extend doesn’t support websocket. That’s the reason the server doesn’t receive your wscat request.
Can you share what your Extend app does in general and what’s the reason you need to use Websocket? Is it acting as a game server, e.g. calculating game physics? This will help us understand your use case so we can recommend the best solution with AGS.
Note As a reminder, please don’t share any sensitive information as this is a public forum.
I hope the Extend app acts as an logic server in our game. It is nothing about the game physics or the scene simulation. It is like player upgrade or the equipment upgrade, but more complex. It may have some timers with it. So the server may send a message to the client at any time.
And to reduce the latency of each request, I want to use the the Bi-directional streaming. Unfortunately, it is not supported on the WebGL platform. On the WebGL platform, I am afraid I have no choice other than WebSocket. And on the server, it is quite easy to integrate it to the server. So that is it.
Hi @user18 ,
In other words, you’re looking to use websocket so you can push information from the Extend app into your game client with low latency. Let me know if I understand this correctly.
Another question. Are you looking to send a request from the game client to the Extend app as well?
Yeah, beside the latency, I need the Bi-directional streaming. Then the server is able to send notice msg to the client. The gRpc on WebGL doesn’t support this feature.
Yes, if the websocket works, I will serialize the request and the response message myself.
You can utilize Lobby service API to send lobby websocket message to player. Your game client can send request to your Extend app via REST API. Upon receiving the request, your Extend app can send a notification to Lobby service, and then Lobby service will forward that to player if they are already connected to Lobby WebSocket.
To be able sending a web socket message via Lobby service, first you will need to create a topic first. For templated message, you will need to create a template first.
You can find relevant endpoints in here
For topic creation, you can use following endpoint or add it manually in admin portal.
To send the message you can use following endpoints:
@rinardi are your responses the result of the discussion @vincentab had with the team? I’m super curious as to how valid of a use case this actually is.
Hi @njupshot
Yes. This is what we think could help resolve this use case. One of our customer does this as well. Let us know if that answer your questions!
It does, thank you @vincentab. It sounds like there’s potential for Extend to act as a game server given that streaming state isn’t needed. For example a turn based game could use your flow above where inputs are sent via HTTP to an extend app, who could then read/write the game state to/from cloud save and then push state changes back to the clients via lobby service websocket. I guess the only unknown there is how matchmaking would fit in.
That’s an interesting use case! However, it’s an uncharted territory as Extend is not designed to be a game server. There are possibilities that the developer needs to build other functionality besides matchmaking integration to use Extend as a game server.