Total.js on iinode return only 404: Not Found
Hello Peter, I'm trying to make the total.js run in my IIS
I have worked with other frameworks and I have not had a problem, I think I'm doing something wrong, or not doing something.
Can you help me?
My release.js file:
const fs = require('fs');
const options = {};
options.ip = 'auto';
options.port = process.env.port;
var framework = require('total.js');
framework.http('release', options);
My controllers/default.js
exports.install = function() {
F.route('/', view_index);
// or
//F.route('/');
};
function view_index() {
var self = this;
self.plain('Demo 2');
}
My web.config
<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="release.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^release.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="{REQUEST_URI}" />
</rule>
<!-- All other URLs are mapped to the Node.js application entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="release.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
IISNODE LOG
====================================================
PID : 11288
Node.js : v7.4.0
Total.js : v2.5.0
OS : win32 10.0.14393
====================================================
Name : Total.js
Version : 1.0.0
Author :
Date : 2017-05-17 01:27:27
Mode : release
====================================================
http://auto:\\.\pipe\104e4909-f788-4450-874b-0c4aee876a3e/



Hi @hessel framework expects the port to be a number but in iisnode process.env.port is a named pipe.
Can you change the options as shown bellow to see if that's the issue:
options.ip = '127.0.0.1';
options.port = 3000;
Thanks
@hessel does it work?
Hi @petersirka and @molda , unfortunately it did not work, it seems to me a problem with the routes.



LOG IISNODE

Thanks!
Can you add this snippet to see the request details? It seems the server is responding just fine but as you said the problem could be with routes.
F.on('request', function(req, res){
console.log(req.method, req.url);
});
I'm currently battling with this right now and has been investigating it. What I've noticed so far is that:
-
Setting the ip and port values directly results in an error logged as
Error: listen EACCES 127.0.0.1:86. Not setting any port or usingprocess.env.PORT(which is NaN) will cause total.js to use the default port of 8000. So while the screen shows that there is error, your application will actually be accessible through port 8000 -
Your applications entry point is actually
interceptor.jswhich resides in iisnode installation folder (in my system itsC:\Program Files\iisnode) andrelease.jsordebug.jsas the case may be. -
Due to the above when total.js tries to get the applications working directory as specified here it retrieves the directory of interceptor which is iisnode's installation folder. Unfortunately, totaljs has no access to this folder. This is evident when it tries to create the "tmp" folder as it throws error . This issue can be resolved by setting the directory value of the options object in
release.jsordebug.js.
It all seems to be more of an iisnode configuration/setup issue than a total.js issue but I might be wrong cause I'm still trying to figure out the whole stuff.
Thanks @BlueMagnificent
I'm still trying to run total.js on iisnode, my idea is to run as web application on Azure, but so far without success.
I believe that only as a reverse proxy will work, but I'm still trying.
@molda I could not return anything, just ignore it.
Tks
Can I debug it from my Mac? What do I need for it?
Hi @petersirka.
- You will need to virtualize a Windows 10 virtual machine (Parallels);
- Attempt IIS in System Resources;
- Install iisnode on https://github.com/tjanczuk/iisnode;
- Create a website pointing to the project folder total.js;
Or
Create a free web application on Azure, but you will not have access to every system to debug, but the web result will be the same.
Thanks for help!
Finally got it to work on my local IIS after much digging deep into express.js and node.js in general. I figured out it was much easier than expected.
const fs = require('fs');
const options = {};
options.port = process.env.PORT;
options.directory = "C:\\Path\\To\\Application";
var framework = require('total.js');
framework.http('release', options);
Yes process.env.PORT is a named pipe in form of a string but node.js still consumes it. Notice that no value for IP was set. I still need to set options.directory because as I mentioned in an earlier post total.js infers the applications directory by first given precedence to the directory of the applications entry point and next to process.cwd(). Unfortunately the application's entry point while using iisnode is usually not our actually *.js files but an interceptor file as specified in the web.config (or interceptor.js by default). The directory of this file may or may not be accessible to the application, like in my case it was by default not accessible cause it resided in C:\Program Files\iisnode .
Setting value for the directory property of the options object helped me circumvent this issue since options.directory has higher precedence than the other two mentioned above. And better still, setting it as options.directory = process.cwd() wraps the whole stuff for me.
Unfortunately I've not tried this on Azure but I believe it should help you out
@BlueMagnificent Thank You!!!
This is the perfect setup to run on IIS, I just tested it on Azure and it worked!
Thank you very much for sharing the solution, I spent many hours with it.
const fs = require('fs');
const options = {};
options.ip = 'auto';
options.port = process.env.port;
options.directory = process.cwd();
var framework = require('total.js');
framework.http('release', options);
@petersirka and @molda please share this information on the total.js website, it will help many people.
And I would like to thank you for all the support, keep up the impeccable work of yours, total.js is amazing!
Thank you.
@BlueMagnificent thank you very much! You saved me a lot of time. I'll add it into the documentation.
@hessel thank you too and yes, I'll add it.
Thank you!
@hessel you are welcomed, I'm glad it helped
@petersirka you are welcomed too, keep up the good work with total.js
I followed everything but i got this error
Try to look into some logs ...
BTW: deprecationWarning: update your Node platform to v11, v12 or v13.
OK, and try to look into IIS logs, maybe there will be a some problem and please follow: https://docs.totaljs.com/latest/en.html#pages~Troubleshooting~(hosting-total-js-applications-in-iis-on-windows)
My previous version of total was working fine but after i updated to latest i got this error..