1

I have a chatting application using node.js server, Few days back we moved from http to https server, Where https server is working fine on web but not on native app, so for this we have created new http server with different port number.

Now I have two node socket.io server, one is http who is working on port 3000(for mobile client) and another one is https who is working on 3001 port(for web client), both the server has a same code, but now I am not able to make communication between native and web user.

So is it possible for node server to listen HTTP and HTTPS request simultaneously on a same port.

or

Is there any way through which I can send HTTp server request to HTTPS server ?

Below is the code for HTTP server

  var app = require('http').createServer(handler),
io =require('socket.io').listen(app);
var querystring = require('querystring');
var http=require('http');
var fs = require('fs');
var webservice_host="xxxxxxxxxxxx.com";
var port = process.argv[2] || 3000;
var authKey="";
MST
  • 113
  • 1
  • 8

1 Answers1

0

I'm not sure if you can get the http and https servers to listen simultaneously on the same port and accept only its protocol.

Is there any way through which I can send HTTp server request to HTTPS server ?

Yes, check out this question that explains how to create an HTTP -> HTTPS proxy. How to use node-http-proxy for HTTP to HTTPS routing?

Community
  • 1
  • 1
Alex Yurkowski
  • 1,676
  • 1
  • 12
  • 26
  • How can it with the socket.io. i.e suppose I have a test_method in node socket api, then how can i call it from the mobile user(who can only able to make HTTP connection) and pass it to the https server. The main condition is that all users are bind to a scoket during communication and I have a number of socket connection. Is it good to go with http-proxy or should I try nginx for this. – MST Oct 12 '15 at 13:32