setting up EasyRTC within my Web Application

827 views
Skip to first unread message

in...@wave-ba.co.uk

unread,
Feb 21, 2014, 11:30:10 AM2/21/14
to eas...@googlegroups.com
I am trying to get the simple audio/video demo to work within my website but am running into issue due mainly to a lack of understanding on how the easyRTC server instance works/runs/listens

i first downloaded node.js after following the installation instructions ib the easyRTC documentation, but im not sure if i actually need it to run easyRTC.

basically i have a website in a windows 8 server setup in IIS such as myweburl.co.uk/ which is on port 80. i created a directory called easyrtc in the root of this website and put the demo files from easyRTC there.

i ran npm install from windows command prompt which created the node_modules without error.

i then modified demo_audio_video_simple.html so that the easyrtc,js and socket-io.js files were properly reference relatively from my web site root ie 

<script src="/easyrtc/node_modules/socket.io/lib/socket.io.js"></script>
<script type="text/javascript" src="/easyrtc/node_modules/easyrtc/api/easyrtc.js"></script>

i also add 

to the connect function as explained in the documentation

i then enter command prompt in windows and run 
  • node server.js
im not sure if im even supposed to do this?

if i browse to the demo page from my desktop PC at home (the website itself is running on a hosted server) i see the page fine and it connects to my camera fine but then i get an UNDEFINED error, nothing more nothing less.

im assuming this has something to do with the fact i havent set up easyrtc server properly. do i need to do the node bit at all or should i be running server.js somehow in IIS, if so how? 

any help on this at all would be most appreciated


Eric Davies

unread,
Feb 21, 2014, 11:55:08 AM2/21/14
to eas...@googlegroups.com
First bit: 
   As the demos are distributed, node serves as your webserver and the signalling server. Your IIS can serve as the webserver but not the signalling server. So, yes, you do need to do the "node server.js" and have it running.

I would suggest trying
easyrtc.setSocketUrl("//myweburl.co.uk:8080");
rather than 
         easyrtc.setSocketUrl("\\myweburl.co.uk:8080");

the \\ was a typo in our documents.

Eric.

  

Ujwal Makhija

unread,
Oct 7, 2014, 10:49:29 AM10/7/14
to eas...@googlegroups.com
I am trying to use the function as:

easyrtc.setSocketUrl("//dev.mydomain.com/demo");

This since I am using an http proxy in front of the application and the /demo forwards to my other url. However, it seems the setSocketUrl does not support a / in the domain name. Is this a constraint? How can I achieve targeting a base URL?

Eric Davies

unread,
Oct 7, 2014, 11:37:07 AM10/7/14
to eas...@googlegroups.com
setSocketUrl passes the URL onto socket.io's connect method without modification. I would first check whether your http proxy also does websocket proxying. From the wikipedia entry on Websockets: 
Some proxy servers are transparent and work fine with WebSocket; others will prevent WebSocket from working correctly, causing the connection to fail. In some cases, additional proxy server configuration may be required, and certain proxy servers may need to be upgraded to support WebSocket.

There has been some discussion on using http proxies in the past. I would suggest that you first search the group for "proxy" and then possibly post  a new question (rather than piggybacking on an unrelated thread) so people familiar with proxies actually see your question. 

Ujwal Makhija

unread,
Oct 7, 2014, 1:53:38 PM10/7/14
to eas...@googlegroups.com
Hi Eric,

Thanks for your suggestion. The problem is not with an http proxy per se. I should have been clearer in my previous post. The node.js services is behind a reverse proxy. So all requests reach the httpd server and this httpd server acts as a reverse proxy passing requests of the form http://mydomain.com/easyrtc to http://internalNodeJsIp/.

I checked my requests on a packet analyser and found that:

easyrtc.setSocketUrl("//dev.mydomain.com:3000"); // works well calling http://dev.mydomain.com:3000/socket.io

easyrtc.setSocketUrl("//dev.mydomain.com/base"); // does not work well; should call http://dev.mydomain.com/base/socket.io, but instead calls http://originServer/socket.io

And so my query on whether a base url patch is permitted on setSocketUrl or not. I hope I am clearer on my query.

Regards,
Ujwal

Eric Davies

unread,
Oct 7, 2014, 3:35:24 PM10/7/14
to eas...@googlegroups.com
Hi Ujwal,

The two relevent easyrtc  functions in the client are as shown below:

    this.setSocketUrl = function(socketUrl) {
        if (self.debugPrinter) {
            self.debugPrinter("WebRTC signaling server URL set to " + socketUrl);
        }
        serverPath = socketUrl;
    };

 function connectToWSServer(successCallback, errorCallback) {
        var i;
        if (preallocatedSocketIo) {
            self.webSocket = preallocatedSocketIo;
        }
        else if (!self.webSocket) {
            self.webSocket = io.connect(serverPath, {
                'connect timeout': 10000,
                'force new connection': true
            });
            ...
        }
      ...
}

What lines would you see changing?

The behavior you are seeing is coming from socket.io. From Socket.io's documentation (http://socket.io/docs/client-api/):

Socket instance is returned for the namespace specified by the
pathname in the URL, defaulting to /. For example, if the url is
http://localhost/users, a transport connection will be established to
http://localhost and a Socket.IO connection will be established to
/users.

There may be some way to change socket.io's behavior to fit your proxy better, but I must admit I haven't seen it in socket.io's "terse" documentation.

Ujwal Makhija

unread,
Oct 8, 2014, 6:14:39 AM10/8/14
to eas...@googlegroups.com
Hi Eric,

The below works

self.webSocket = io.connect(serverPath, {
'resource' : 'myapp/socket.io',
                'connect timeout': 10000,
                'force new connection': true
            });

Thanks for your help.

As a further remark, post the above and while using reverseproxy, a WS Tunnel also needs to be created.

Regards,
Ujwal

Eric Davies

unread,
Oct 9, 2014, 12:14:58 AM10/9/14
to eas...@googlegroups.com
You've convinced me! I'll add the ability to set the options tomorrow.

John B Dougherty

unread,
Mar 15, 2015, 2:12:22 AM3/15/15
to eas...@googlegroups.com
<script src="/easyrtc/node_modules/socket.io/lib/socket.io.js"></script>
<script type="text/javascript" src="/easyrtc/node_modules/easyrtc/api/easyrtc.js"></script>

There are two socket.io.js scripts, and the one in


is the one my demo_audio_video_simple.html is calling.
Reply all
Reply to author
Forward
0 new messages