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

WebRTC problem #40

Open
pantrombka opened this issue Mar 8, 2017 · 16 comments
Open

WebRTC problem #40

pantrombka opened this issue Mar 8, 2017 · 16 comments

Comments

@pantrombka
Copy link

I have a problem with webrtc transport in eureca.io.
I installed on my VPS module wrtc.
My server.js:

var http = require('http');
var fs = require('fs');

var server = http.createServer();

var Eureca = require('eureca.io');

var eurecaServer = new Eureca.Server({transport:'webrtc', allow:['hello', 'sub']});

eurecaServer.attach(server);

//functions under "exports" namespace will
//be exposed to client side
eurecaServer.exports.hello = function () {
    var client = eurecaServer.getClient(this.connection.id);
    client.hello();
    console.log('Hello from client');
	return ('hello return');
}


eurecaServer.onConnect(function (conn) {
    
    console.log('new Client');
    var client = eurecaServer.getClient(conn.id);
    

    
    client.sub(10, 4).onReady(function (r) {
        console.log('> 10 - 4 = ', r);
    });
    
});




server.on('request', function (request, response) {
    var i;
    
    if (request.method === 'GET') {
        
        if (request.url.split('?')[0] === '/') {
            var filename = __dirname + '/index.html';
            fs.readFile(filename, function (err, data) {
                var text = data.toString();
                response.writeHead(200, { 'Content-Type': 'text/html' });
                response.write(text);
                response.end();
            });
        }
    }

});


console.log('\033[96mlistening on 8000 \033[39m');
server.listen(8000);

and client.html:

<!doctype html>
<html>
    <head>
        <title>Engine.io test</title>
        <script src="/eureca.js"></script>
    </head>
    <body>    
        <script>
            var client = new Eureca.Client({  uri: 'http://myip:8000', transport: 'webrtc', reliable: false, maxRetransmits:3, ordered:true});
            client.exports.hello = function () {
                console.log('hello from server');
            }
            client.exports.sub = function (a, b) {
                return a - b;
            }
            client.ready(function (proxy) {
                proxy.hello().onReady(function (r) {
                    console.log('returned ', r);
                });
            });
        </script>
    </body>
</html>

On server I see only:

* using webrtc
listening on 8000

On client:

* using webrtc
http://myip:8000 eureca.io

Where is the problem?

@alaa-eddine
Copy link
Contributor

Hi @pantrombka
Please note that webrtc support is experimental, because there is no official nodejs support for webrtc.

regarding your issue, it's not easy to tell what's going on from the above description but here are some hints .

first, disable webrtc and use the default eureca.io transport library to check that there is no other networking issue. if it work with the default transport switch back to webrtc.

activate the debug output using :

export DEBUG="*"

then run your server and open your client, the output could tell us what's wrong .

in the client side, use chrome/chromium browser and open development tab, and check what's going on in networking tab and console tab.

@pantrombka
Copy link
Author

I remove transport: 'webrtc'. It works. With transport: 'webrtc' and export DEBUG="*" I can't see any messages - only

* using webrtc
listening on 8000

and

* using webrtc
http://myip:8000 eureca.io

I changed transport: 'webrtc' to transport: 'webRTC' and I see errors:

* using primus:webRTC
primus transformer `json` is a string, attempting to resolve location
primus transformer `webRTC` is a string, attempting to resolve location
primus the supplied transformer webrtc is not supported, please use [object Object]
Primus:
Primus: Unsupported transformer: "webrtc"
Primus: We only support the following transformers:
Primus:
Primus:   websockets, engine.io, browserchannel, sockjs, faye, uws
Primus:

@alaa-eddine
Copy link
Contributor

the correct syntax is "webrtc" in lowercase.

it strange that the debug directive is ignored, you are on a linux environment right ?

@pantrombka
Copy link
Author

Yes, I am in linux. Command export DEBUG="*" looks OK
echo $DEBUG
index.html server.js
and other files

node -v
v7.7.1

@alaa-eddine
Copy link
Contributor

when you type echo $DEBUG do you see the value "*" ?
if not, you need to set it.

the latest version of nodejs I tested was 6.x there are maybe some breaking change in the latest version or in node-webrtc package, I'll try to make new tests asap.

@pantrombka
Copy link
Author

I changed nodejs to v6.10.0. Still nothing.
npm node-webrtc -v
3.10.10
This look like server is working, but messasing are blocking.

@pantrombka
Copy link
Author

When I remove " transport: 'webrtc' " I see Debug messages on the server.

@pantrombka
Copy link
Author

Sorry, verion of my modules:

npm list eureca.io
eureca.io@0.6.42
npm list wrtc
wrtc@0.0.61

@alaa-eddine
Copy link
Contributor

I just pushed the newest version to npm (it was only available on github).
can you please update eureca.io and try again ?
I don't think that it'll resolve the issue since the last update didn't modified webrtc behaviour, but just to make sure you have the latest version.

@pantrombka
Copy link
Author

Now I have eureca.io v0.7.1.
Unfortunately, problem still exist.

@alaa-eddine
Copy link
Contributor

Can you please share what you see in the client side in chrome developement tools, Console and network tabs ?

make sure to enable chrome dev tools, then refresh the client .

@pantrombka
Copy link
Author

@pantrombka
Copy link
Author

On Firefox console:
eureca.js:398: RTCIceServer.url is deprecated! Use urls instead.

@pantrombka
Copy link
Author

I still have a problem with WebRTC, but I wonder whether in my project (something like http://ezelia.com/2014/tutorial-creating-basic-multiplayer-game-phaser-eureca-io) using of webRTC is good? Performance will be better?

@alaa-eddine
Copy link
Contributor

Sorry for the delay.
the webRTC issue will take some time to fix, it seems to be related to deprecated functions in the browser side, plus some code changes in node-webrtc side ... :/

regarding the implementation, for simple multiplayer games, it won't make lot of change in performance, I made this tutorial only to show how to implement very basic multiplayer logic, it's not optimized at all !
the lags that you may encounter are because the code don't implement any lag compensation algorithm, it use a "dumb" aproach which consist in boradcasting all players' commands.

WebRTC can be interesting in massive multiplayer games, and realtime multiplayer games . but since webRTC transport is not reliable, it'll require that you implement code to handle cases when the call fails ...etc.
so it really depend on what you are trying to do.

in most cases, the standard transports are enought, you just need to make good implementation, sometimes with lag compensation algorithms, sometimes with other technics.

@pantrombka
Copy link
Author

I think, it could be useful for me. So I will be waiting for fix. Thank you!

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

2 participants