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

RTCMultiConnection Server post request returns bad handshake error #29

Open
adares2 opened this issue Dec 7, 2020 · 4 comments
Open

Comments

@adares2
Copy link

adares2 commented Dec 7, 2020

I have a docker nginx symfony vue stack under exampledomain.com
I implemented RTCMulticonnection with

<script type="application/javascript"  src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script type="application/javascript"  src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script> 

and in my Vue File

this.rtcmConnection = new RTCMultiConnection();
this.rtcmConnection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

everything was working. Now i wanted to use my own signaling server. I started one with the following Dockerfile

FROM node

RUN git clone https://github.com/muaz-khan/RTCMultiConnection-Server \
    && cd RTCMultiConnection-Server \
    && npm install

CMD (cd RTCMultiConnection-Server && node server.js)

EXPOSE 9001

I modified config.json with the ssl configuration of my nginx server.
and in the server.js i make this changes:

var iooptions = {
        allowUpgrades: true,
        transports: ['polling', 'websocket' ],
        cors: {
          origin: ['https://www.exampledomain.com','https://exampledomain.com'],
          credentials: true,
          methods: 'GET'
        }
};

ioServer(httpApp,iooptions).on('connection', function(socket) {
 ...
}

Now the server is up and running under
https://exampledomain.com:9001/

and used it in vue with:

this.rtcmConnection.socketURL = 'https://exampledomain.com:9001/';

the browser tries to connect with signaling server with get and post


https://exampledomain.com:9001/socket.io/?userid=ovdo1uhmxtj7l4p4fs&sessionid=1c7ec8af2eacf1cdc828a54abc72e85a&msgEvent=RTCMultiConnection-Message&socketCustomEvent=RTCMultiConnection-Custom-Message&autoCloseEntireSession=false&maxParticipantsAllowed=1000&extra={}&EIO=3&transport=polling&t=NOeBTVe

the get request seems to be okay

but the post request is a 400 bad request and returns a json bad handshake error.

How can I fix the error and connect?

@danielehrhardt
Copy link

Duplicate of #28

@arunkumartdr
Copy link

arunkumartdr commented Oct 13, 2021

@nurassyl @gbrian @muaz-khan

above solution not workingt in http://localhost:9001

// --------------------------
// socket.io codes goes below

var iooptions = {
        allowUpgrades: true,
        transports: ['polling', 'websocket' ],
        cors: {
          origin: ['https://localhost','http://localhost'],
          credentials: true,
          methods: 'GET'
        }
};

ioServer(httpApp,iooptions).on('connection', function(socket) {
    RTCMultiConnectionServer.addSocket(socket, config);

    // ----------------------
    // below code is optional

    const params = socket.handshake.query;

    if (!params.socketCustomEvent) {
        params.socketCustomEvent = 'custom-message';
    }

    socket.on(params.socketCustomEvent, function(message) {
        socket.broadcast.emit(params.socketCustomEvent, message);
    });
});

image

i had Tried to connect like this:

connection.socketURL = 'http://localhost:9001/';

@wanaideed
Copy link

wanaideed commented Mar 24, 2022

@arunkumartdr did you get any solution at your problem? I got a same error. can't run as localhost.

@muaz-khan @nurassyl @gbrian @mirza Brunjadze

@wanaideed
Copy link

Done. I solve the problem with install socket.io version 2.

run cmd npm install [email protected]

can visit https://medium.com/@aideedprogrammer/video-broadcast-webrtc-using-ionic-apps-14affc0a8369

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

No branches or pull requests

4 participants