heroiclabs / nakama-js

JavaScript client for Nakama server written in TypeScript.
https://heroiclabs.com/docs/nakama/client-libraries/javascript/
Apache License 2.0
182 stars 54 forks source link

Connect socket to different port or host #158

Closed suman-majhi closed 1 year ago

suman-majhi commented 1 year ago

In the current client.ts file, there is no option to change host or port while connecting to socket

createSocket(useSSL = false, verbose: boolean = false, adapter : WebSocketAdapter = new WebSocketAdapterText(), sendTimeoutMs : number = DefaultSocket.DefaultSendTimeoutMs): Socket {
  return new DefaultSocket(this.host, this.port, useSSL, verbose, adapter, sendTimeoutMs);
}

It will take the same host and port added at Client creation time.

Can we have a separate custom createSocket function that will take host and port as argument?

lugehorsam commented 1 year ago

Hey @suman-majhi could you share your use case for wanting to connecting to a different host or port with the socket than the client?

suman-majhi commented 1 year ago

In our backend architecture, we have two ports rpc and ws to connect with. For the client creation time, rpc port (ex: 33650) is being used and the same port is used for authenticateCustom (which is fine). But for the webSocket connection, we will need ws port (ex: 33649)(with same IP). And currently, there is no other way we can implement it.

@lugehorsam

lugehorsam commented 1 year ago

This is not a pattern we are looking to support in our clients or Nakama at this time. We can't support custom infrastructure setups from our SDKs. Nakama is currently built to only accept WebSocket connections over HTTP on the same port that it listens to all other client requests from.

If you are looking for a good infrastructure solution to hosting multiple Nakama nodes, we recommend Heroic Cloud.