Cannot resolve socket io client api call

575 views
Skip to first unread message

Carrie

unread,
Aug 7, 2015, 1:31:24 PM8/7/15
to EasyRTC
I have scoured the web and tried every hack and quirk out there, yet still cannot get socket io client api call to resolve through easyrtc. I am using iisnode and express 3.x, along with socket.io 0.9.x

iisnode tells me servers are starting, but client cannot resolve url. Both apis (easyrtc and socket.io) are hosted in iis. 

info: socket.io started
info    - EasyRTC: Starting EasyRTC Server (v1.0.14) on Node (v0.12.7)
info    - EasyRTC: EasyRTC Server Ready For Connections (v1.0.14)

server.js

var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io').listen(server);

server.listen(process.env.PORT);

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

// Start EasyRTC server
var rtc = easyrtc.listen(app, io);

app.use(express.static(__dirname + "/static/"));
app.get('/nodejs/videoconference', function(req, res) {
var file = fs.readFileSync(__dirname + '/static/vc.html', {encoding: 'utf8'});
res.send(file);
//res.send('hello from [carrie] in pmwebs - would serve:' + path.join(__dirname + '/static/vc.html'));
});

io.configure(function(){
  io.set('transports',['xhr-polling']); //Use long-polling instead of websockets!
  io.set('resource', '/node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js'); //Where we'll listen for connections.
});

io.on('connection', function(socket) {
    //emit and listen messages
console.log('hello world i am a hot socket');
});

vc.html (client)

<html>
<head>
    <title>Video Conference</title>
<link rel="stylesheet" type="text/css" href="/easyrtc/easyrtc.css" />
<script src="/socket.io/socket.io.js"></script>
<script src="/easyrtc/easyrtc.js"></script>
<script>
var selfEasyrtcid = "";

function connect() {
//easyrtc.setSocketUrl("//192.168.1.126:443");
easyrtc.enableDebug(true);
easyrtc.setVideoDims(640,480);
easyrtc.setRoomOccupantListener(convertListToButtons);
easyrtc.easyApp("emmchat", "selfVideo", ["callerVideo"], loginSuccess, loginFailure);
}

function clearConnectList() {
var otherClientDiv = document.getElementById('otherClients');
while (otherClientDiv.hasChildNodes()) {
otherClientDiv.removeChild(otherClientDiv.lastChild);
}
}

function convertListToButtons (roomName, data, isPrimary) {
clearConnectList();
var otherClientDiv = document.getElementById('otherClients');
for(var easyrtcid in data) {
var button = document.createElement('button');
button.onclick = function(easyrtcid) {
return function() {
performCall(easyrtcid);
};
}(easyrtcid);

var label = document.createTextNode(easyrtc.idToName(easyrtcid));
button.appendChild(label);
otherClientDiv.appendChild(button);
}
}

function performCall(otherEasyrtcid) {
easyrtc.hangupAll();

var successCB = function() {};
var failureCB = function() {};
easyrtc.call(otherEasyrtcid, successCB, failureCB);
}

function loginSuccess(easyrtcid) {
selfEasyrtcid = easyrtcid;
document.getElementById("iam").innerHTML = "I am " + easyrtc.cleanId(easyrtcid);
}

function loginFailure(errorCode, message) {
easyrtc.showError(errorCode, message);
}
</script>
</head>
<body onload="connect()"><!---->
    <div id="demoContainer">
<div id="connectControls">
<div id="iam">Not yet connected...</div>
<br />
<strong>Connected users:</strong>
<div id="otherClients"></div>
</div>
<div id="videos">
<video autoplay="autoplay" class="easyrtcMirror" id="selfVideo" muted="muted" volume="0" ></video>
<div style="position:relative;float:left;">
<video autoplay="autoplay" id="callerVideo"></video>
</div>
</div>
</div>
</body>
</html>

Html page is served fine from server.js express via app.get() however when a call to socket io api is made it results in a 404. If I hit myapp/socket.io/socket.io.js it DOES serve the js...please HELP!?!?

Response:

debug 2015-08-07T17:19:48.499Z : about to request local media [    at initMediaSource (https://192.168.1.126/easyrtc/easyrtc.js:1984:18)]
easyrtc.js:814 debug 2015-08-07T17:19:49.531Z : getUserMedia success callback entered [    at initMediaSource.onUserMediaSuccess (https://192.168.1.126/easyrtc/easyrtc.js:2024:22)]
easyrtc.js:814 debug 2015-08-07T17:19:49.533Z : successfully got local media [    at initMediaSource.onUserMediaSuccess (https://192.168.1.126/easyrtc/easyrtc.js:2028:22)]
easyrtc.js:814 debug 2015-08-07T17:19:51.353Z : attempt to connect to WebRTC signalling server with application name=emmchat [    at connect (https://192.168.1.126/easyrtc/easyrtc.js:5459:18)]
socket.io.js:1659 GET https://192.168.1.126/socket.io/1/?t=1438967991355 404 (Not Found)Socket.handshake @ socket.io.js:1659Socket.connect @ socket.io.js:1699Socket @ socket.io.js:1551io.connect @ socket.io.js:94connectToWSServer @ easyrtc.js:4464connect @ easyrtc.js:5468postGetUserMedia @ easyrtc.js:5391initMediaSource.tryToGetSize @ easyrtc.js:2062
easyrtc.js:814 debug 2015-08-07T17:19:51.404Z : saw error Unable to reach the EasyRTC signalling server. [    at onError (https://192.168.1.126/easyrtc/easyrtc.js:1354:18)]
easyrtc.js:814 debug 2015-08-07T17:19:51.453Z : cfg={"userSettings":{"sharingAudio":true,"sharingVideo":true,"sharingData":false,"nativeVideoWidth":640,"nativeVideoHeight":480,"windowWidth":1920,"windowHeight":304,"screenWidth":1920,"screenHeight":1200,"cookieEnabled":true,"language":"en-US"}} [    at sendDeltas (https://192.168.1.126/easyrtc/easyrtc.js:4663:26)]
easyrtc.js:814 debug 2015-08-07T17:19:51.454Z : sending socket message {"msgType":"setUserCfg","msgData":{"setUserCfg":{"userSettings":{"sharingAudio":true,"sharingVideo":true,"sharingData":false,"nativeVideoWidth":640,"nativeVideoHeight":480,"windowWidth":1920,"windowHeight":304,"screenWidth":1920,"screenHeight":1200,"cookieEnabled":true,"language":"en-US"}}}} [    at sendSignalling (https://192.168.1.126/easyrtc/easyrtc.js:2734:22)]

Eric Davies

unread,
Aug 7, 2015, 2:09:17 PM8/7/15
to EasyRTC
I'm not an iisnode person, so there may be stuff that is implicit that I'm missing.

It's not clear what you are trying to accomplish:
  are you trying to serve pages using IIS and using iisnode to handle the websocket, or
  are you trying to iisnode handle serving pages and websocket?

If the former, you probably want to follow the instructions in http://easyrtc.com/docs/guides/easyrtc_with_other_servers.php . In either case, I think you'll want to run node on a different port than what iis is already managing to avoid conflicts. Any iinode users care to chime in?

Carrie

unread,
Aug 7, 2015, 2:35:45 PM8/7/15
to EasyRTC
What I'm trying to accomplish is a simple audio/video chat. We are normally a .NET shop, but are embracing nodejs. The way the production servers are set up, the chat app must be a sub-site of IIS site running https. It doesn't matter who serves the page, as long as the easyrtc & socket servers get started prior to the pages js executing. I've not found any examples combining the easyrtc simple audio video chat with serving an html page containing client script...

Eric Davies

unread,
Aug 7, 2015, 4:36:26 PM8/7/15
to EasyRTC
You've disabled websocket handling in IIS as per http://tomasz.janczuk.org/2012/11/how-to-use-websockets-with-nodejs-apps.html ?

Using WebSockets in a node.js applications running in iisnode requires that – contrary to what one would expect – websockets are disabled in web.config:

1 <configuration>  
2   <system.webServer>  
3     <webSocket enabled="false" />  
4     <handlers>  
5       <add name="iisnode" path="server-faye.js" verb="*" modules="iisnode" />  
6     </handlers>  
7   </system.webServer>  
8 </configuration>

This is required because IIS 8 provides its own implementation of the WebSocket protocol that builds on top of the HTTP Upgrade mechanism. If the IIS 8 WebSocket module remained enabled, it would conflict with the WebSocket implementation provided by the node.js application itself in the form of one of the node.js modules, e.g. faye-websocket, ws, or socket.io. The IIS 8 WebSocket module is used to enable WebSocket functionality in ASP.NET applications.

Carrie

unread,
Aug 10, 2015, 10:43:06 AM8/10/15
to eas...@googlegroups.com
I do. This web.config seems pretty standard, although I gave up on serving user.js for the moment and just include my client script in the html page for simplicity. Here is web.config:


Enter code here...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="off" />
</system.web>
  <system.webServer> 
  <httpErrors existingResponse="PassThrough" />  
    <!-- indicates that the server.js file is a node.js application 
    to be handled by the iisnode module --> 
    <handlers>
      <add name="iisnode" path="server.js" verb="*" modules="iisnode" />   
    </handlers>
<rewrite>
 <rules>
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="iisnode" />
        </rule>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>
<rule name="StaticContent">  
<action type="Rewrite" url="static{REQUEST_URI}"/>  
</rule>
<rule name="DynamicContent">  
<conditions>  
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> 
</conditions>  
<action type="Rewrite" url="server.js"/>
</rule>
 </rules>  
</rewrite>
<webSocket enabled="false" />
<iisnode debugHeaderEnabled="true" debuggingEnabled="true" nodeProcessCountPerApplication="1" loggingEnabled="true" />
  </system.webServer>
</configuration>

Eric Davies

unread,
Aug 10, 2015, 1:47:26 PM8/10/15
to EasyRTC
Given the lack of responses from other people, I'm going to guess that you aren't many iisnode users here.

You'll probably have more luck finding an iisnode discussion group and asking if somebody there can show you how to a subsite with iisnode with websockets. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages