Using ASP.Net MVC & node.js together - asp.net-mvc

I am writing a ASP.Net MVC app that connects to a SQL database and uses existing C# libraries I have.
I also have a TCP server Windows application that sends/receives TCP messages via XML. I have successfully setup node.js and socket.io to handle all this and have a html page that sends/receives messages to the server. Node.js is serving up the html page at the moment. The XML is converted to JSON when sending/receiving data.
I am planning on setting my MVC app to serve the page up but was just wondering what your thoughts are on this use of cross framework setup. Does it seem viable and a good solution for handling TCP messages and sending it to the browser? I have also read about iisnode for hosting node in IIS which I guess would be a good idea for my setup. What are your thoughts on this?

You basically have two websites. One is your ASP.NET MVC website. and the other is a web client for your TCP windows application.
Since they are disjoint it will work fine.
You may want to have that web client's html server through ASP.NET MVC and only run a websocket server on node.js though. You may need to do some proxying to get the same origin to work.
If you server your HTML page from a webserver running IP Y, port X and then try to talk to the node.js websocket server running on IP Y, port X + n it may violate the same origin restriction.
This means your basically loading a socket.io client from server A and trying to talk to server B. The web page doesn't know you own both of these servers.
The solution would be a proxy, you proxy all requests to server A and B but since they all go through the proxy it doesnt violate the same origin.
As for proxy, nginx is one. There is a node-proxy. And IIS might be able to proxy it for you (Although I doubt IIS makes a good proxy)

Related

mORMot responding to HTTP requests on port 80 instead of IIS

The website of our company is running on IIS 7.5, recently and without any modifications in the configuration, the website start to give us the error 404, here is a picture of the error :
the website work fine with HTTPS and HTTP on every port except the port 80, and we have never used MorMot
Do you have any ideas where this problem comes from ?
There is a registration mechanism for URI on Windows, when using http.sys. It is a kernel/system component, handling HTTP/HTTPS requests.
This registration is shared by IIS and other programs using http.sys, like WCF or mORMot projects.
From the HTML returned, there is clearly a mORMot-powered executable running on the server, which is bound to port 80. You have to identify this program and fix its configuration, to use another port or another sub-URI on port 80, to share it with IIS.
One big benefit of http.sys - in addition to its performance - is that you can share URIs on the same (sub)domain between executables, but you need to register the sub-URI. This is a standard mechanism under Windows - please check this reference page for instance.
Another possibility may be to use IIS as reverse proxy, and run the mORMot-powered executable on a local non-routed port, if you have troubles with http.sys configuration (which is not easy).

How to implement telnet GUI for RoR web application

I want to create a feature on my web portal where a user can click a link to open a telnet session in the browser itself. I researched the Net::Telnet library for Ruby. It has information on how to set up the connection.
But what about the web UI?
How to leverage the Net::Telnet library on the rails web app.
I have Rails 4.2.0 with Apache Passenger running on a CentOS 6.6 machine.
Because telnet is a streaming/serial type protocol and users will expect that type of experience, you might want to look into websockets or streaming http. The only other option would be to do polling to keep your view updated which seems like a very bad fit for a telnet client. Definitely an interesting problem. It appears that Net::Telnet behaves like a tcp socket connection so if you can wire that up to an http stream, which seems possible, you should be able to push it to a browser UI. Sounds like a cool project. Let me know how it takes shape.

.Net MVC Server to Server communications

I need to do some simple comms between two sites, including the case where the same website acts as both the client and server.
The client needs to call a server function with signature something like:
complexObject GetData( int, string)
I'm on c#, .Net MVC 4.5 and running on Windows 7 for dev and & Server 2008 for hosting. I'm looking at both Websockets and SignalR, but can't decide on suitability (I don't need javsacript support, it's purely client/server). There also seems to be limitations running Websockets below Windows server 2012, and on combining client & server in the same app/website ( I could remove that requirement if its a serious issue).
Any advice on the right way to go would be great.
You cannot use WebSocket in ASP.NET unless you are using Internet Information Server 8, so you would need Windows 8 or Windows 2012 server.
SignalR will fallback to SSE, ForeverFrame or LongPolling if you are not using IIS8. SSE is unidirectional from server to client, and does not work in IE.
You can host a WebSocket component in a worker role, that runs in the same domain but in different port. Running in the same domain, the WS connection will send the cookie during the HTTP negotiation, but you would have to work out how to associate the user identity.
You can use for example:
XSocket.NET: http://xsockets.net/
SuperSocket: http://superwebsocket.codeplex.com/
That said, you can still use other technologies for communicating from server to server, like a duplex WCF channel.
A Beginner's Guide to Duplex WCF
Duplex Service in WCF
Cheers.

HTTPS website accessing HTTP WCF service

I have deployed an MVC web application on IIS, and it is configured to run over HTTPS.
Further, the website is consuming a WCF service which is deployed on other server (in same network). The WCF service is running over HTTP.
Everything seems working fine, but while accessing the website it is always giving following message on IE 8.
How can we make the site accessible without the below message getting displayed? Also, the solution should not entail any changes at client-level. I need a solution which can be done at site-level.
it seems that you have enabled https and want to consume service vai http. so please change your serviceMetadata
<serviceMetadata httpsGetEnabled="true"/>
to
<serviceMetadata httpGetEnabled="true"/>
If you are calling the WCF service from client script then the error is just warning the user of mixed content mode.
I would suggest you change the binding for the WCF service and call that over ssl. If its important enough for the site to be running over ssl surely this also goes for the wcf service?

Integrating Guacamole Java Servlet with Rails project

I'm trying to add Guacamole (An html5 vnc client) to an existing rails project but I'm running into some trouble because the Guacamole server is implemented in Java. Based on the overview here http://guac-dev.org/doc/gug/writing-you-own-guacamole-app.html, I need to create 1. a GuacamoleHTTPTunnelServlet (a tunnel between the JavaScript client and the Guacd service) and 2. the javascript client itself. See attached picture for reference. Creating the javascript client seems easy because all the javascript is already given and I would just have to add it to a rails view. The hard part, if possible at all, is integrating the GuacamoleHTTPTunnelServlet java servlet with rails.
Is there any way to have rails serve up the javascript but have the javascript communicate with a different server on the same machine? I'm guessing no because of the same origin policy.
Is there any way to forward the javascript calls from rails server -> java servlet without losing performance? I'm not completely clear on how the javascript client communicates with the server but I think it's passing java objects.
I've never tried anything like this before so please excuse me for any stupidity.
I played around with guacamole and I think your best option is to rewrite guacamole backend (that comunicates with guacd daemon) in rails. Anyway I will try to answer to your questions:
You can proxy ajax requests with rack, ex:
How do I proxy AJAX requests with Rack Middleware?
Another way is to use a reverse proxy (nginx?), ex:
http://yourdomain.com/your/rails/view/url
http://yourdomain.com/guacamole
In this manner the client (browser) will think that your applications are under the same host, avoiding the javascript same origin policy. An iframe will be a great solution.
Javascript communicates with tunnel servlet that proxies requests to guacd daemon (no java objects, just a custom protocol). To speed up performances you can use a reverse proxy (answer 1, ex: nginx) instead of ruby/rack solution.
I hope this can help :)

Resources