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

Client side socket.io cannot be configured to accept path options #307

Open
acuhlmann opened this issue Jan 11, 2022 · 7 comments
Open

Client side socket.io cannot be configured to accept path options #307

acuhlmann opened this issue Jan 11, 2022 · 7 comments

Comments

@acuhlmann
Copy link

I'm trying to use networked-aframe with socket.io on a context path eg localhost:8080/my-app. But how can I configure the client-side socket.io part with that path as it goes by default to localhost:8080/socket.io? Seems it's not configurable as I'm not seeing a second param being passed into the socket.io constructor with path as a field in https://github.com/networked-aframe/networked-aframe/blob/master/src/adapters/naf-socketio-adapter.js#L71

AFAIK, it should be something like const socket = self.socket = io(self.wsUrl, {path: myPath});
or make all options configurable instead of just path.

@vincentfretin
Copy link
Member

PR welcome, you can maybe add a setServerOptions function similar to setServerUrl.

@vincentfretin
Copy link
Member

For setServerUrl, this is called by the networked-scene component from the serverUrl field set on it.
But when I wrote my above comment, I had in mind what the janus adapter is doing, the janus adapter is setting additional info, see the example https://github.com/networked-aframe/naf-janus-adapter/blob/61e155863ed904a47a340a8d05ce029cbb92e795/examples/index.html#L123-L125 it has a setClientId(clientId), setJoinToken(jwt) API that you can call in a adapter-ready listener.

@vincentfretin
Copy link
Member

Your need was for the socketio adapter, but I had the same question for the easyrtc adapter on slack. The easyrtc adapter is using the open-easyrtc lib that uses also socketio, so in the end it's the same.
There seems to be the support for a second param for easyrtc.setSocketUrl see
https://github.com/open-easyrtc/open-easyrtc/blob/23030e61340ed2590295bd88326afe6cc83565e0/api/easyrtc_int.js#L2693-L2699
and
https://github.com/open-easyrtc/open-easyrtc/blob/23030e61340ed2590295bd88326afe6cc83565e0/api/easyrtc_int.js#L5947
that set the options when calling io.connect.

In

setServerUrl(url) {
this.easyrtc.setSocketUrl(url);
}

you can probably try replacing by

setServerUrl(url, options) {
    this.easyrtc.setSocketUrl(url, options);
  }

and call setServerUrl with the two arguments yourself in an adapter-ready listener.

@Rsquare-14
Copy link

Hello @vincentfretin I am using the socket.io with easyrtc adapter and I want to add path through options.
But when I am using setServerUrl as below, the pollings requests are giving 200 OK but the upgrade request for webscoket is not giving any response.
setServerUrl(url, options) { this.easyrtc.setSocketUrl(url, options); }

Can you help?

@vincentfretin
Copy link
Member

I don't have the bandwidth to help on this particular issue in the coming weeks. What I described may not work? Do you folks have already successfully configured a simple express nodejs server using socketio (no naf at all) with what you're trying to do? In which context do you need to host at a specific path? You're using your own VM, nginx in front?

@Rsquare-14
Copy link

Rsquare-14 commented May 27, 2022

Hello @vincentfretin, I have figured out the why the websocket connection is not giving 101 switching protocols response. Thanks to you.
I am hosting my application in AWS using nginx in front. In this https version, the secured websocket is giving unexpected response. Should I change my ngnix configuration? Please help when you get free. Thanks in advance.

@vincentfretin
Copy link
Member

I wrote a guide for configuring nginx in front of janus ws in a VM https://github.com/networked-aframe/naf-janus-adapter/blob/master/docs/janus-deployment.md#nginx-configuration that may help you?
For nodejs socketio behind nginx, this is very similar, just replace the /janus route by /socket.io and the correct port if I remember.

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

No branches or pull requests

3 participants