Socket.io Official Chat application not work on firebase - node.js

I deploy the Socket.io Official Chat application on Firebase, but it always show https://.firebaseapp.com/socket.io/ [HTTP/1.1 404 Not Found] in the console. How to fix this problem?? And It works on my local machine http://localhost:3000
Should I change var http = require('http').Server(app); to
var http = require('https').Server(app);
Because Firebase Hosting is SSL-only.
Any help would be much appreciated. Best Regards.

Firebase Hosting is for static assets only. You cannot run your own node scripts on its servers. This means there is no way to run the socket.io chat app on Firebase Hosting.
Fun fact: Firebase also offers a real-time database, which can be used to very easily build a chat application. Have a look at the interactive tutorial to get a feel for it.

Related

Socket.io, Unreal, & Heroku (Node js) : Client not connecting to server?

I'm currently working on a game that connects to a Node.js server for multiplayer data.
The game is developed in Unreal Engine 4 and uses the Socket.io plugin to connect to the Node.js server (cors, express being used).
Everything works locally. So now I'm trying to move on to hosting the server remotely and connecting the unreal client to the remote Node.js server.
I looked into Heroku and set myself up, everything is working fine on its end to my knowledge - I created a tester page with a success message when you load the URL and that comes through.
My first question is - what am I doing wrong when I use unreal to point the socket.io plugin to the server url?
The socket.io plugin asks for a port #, I've tried the following:
http:/{my server/heroku url}:8080/
http:/{my server/heroku url}:3000/
http:/{my server/heroku url}:18279/ (which was given to me by Heroku).
http:/{my server/heroku url}/
So far the game does not connect to the deployed server, the way it does locally.
Any suggestions on what could be going wrong/what am I failing to do next?
A few things after researching:
I do have http-session-affinity enabled
Since the server is working locally, I'm going to make the assumption that the deployed code is not the issue, and that it has to do with the way I'm trying to connect.
is it possible that I have further authorization to config? Such as allowing the unreal game/client to connect to the server/that the client is being blocked some how?
I figured out the issue, it had to do with how my Node.js server code was calling socket.io.
If you come across this issue please send me a message or comment here and I will be happy to send you the code that worked.

Websocket not working in React.Js production build

I created a react App which talks to a node back-end. Everything works fine in development mode. The connection between the front-end and back-end is made through websocket.
Most interesting thing is, that after doing yarn build to create the production build of the app, all the pages work fine. The only thing is that, the page that integrates connection with the back-end is returning error when I inspected it in the browser. I am using Apache Server to run the build version of the app on localhost.
I am using Apache server since python server throws errors on page refresh.
Below is the screenshot. As you can see, node server command, return the expected response from the backend app. The structure of the app is also shown; revealing the relationship between the front-end (smartschool and smartresult) and back-end (smartapi). Only the smartresult makes the request to back-end. How do I resolve this connection problem? Any help will be appreciated. Thank you.

How can I access Heroku NodeJS server externally?

I have a websocket server running via NodeJS, and have deployed it to Heroku. There are two separate web applications I wrote that communicate with the websocket server. On localhost, I simply run the node server, load up the applications in a web browser, and all works fine. In Heroku, however, I can't seem to get anything to connect to the url ws://url:port - it just returns an err request timeout.
I don't want to deploy my html using Express per their example. Maybe I could, but this is a test case where some web applications get to be pretty huge.
Is my issue that I have to use wss instead of ws?
Or backing up further, is this a good use case for Heroku or is there something else I should use?
The easiest description of what I'm trying to do: Two websites hosted somewhere that isn't Heroku both communicating with a NodeJS-based websocket server hosted on Heroku.
Thanks for your help!
Alright, I feel pretty dumb because this is about as easy an answer as it gets. For anyone else trying to do the same thing, you don't need to specify the port (Heroku port is for internal use only, and the heroku url you are provided is on port 80). Simply connect using wss (e.g. wss://your-app.herokuapp.com)

Deploying React native app with node server to the store

I feel like I have exhausted all possible searches and documentation trying to figure this out. I have a React native app which runs perfectly locally with a node server with websockets, I will like to know steps on how I could deploy this app to the store. I understand the server has to be hosted for example on heroku, but the workaround of the whole process from local server to heroku, then AppStore still confuses me. I will appreciate any suggestions, or clarification on how I could achieve this(deploying server and connecting to React native). Thanks
Host your Node.js server;
Use the remote server's endpoint on the app;
This can be useful to have a dynamic endpoint (dev and production env):
const endpoint = __DEV__ ? 'http://localhost:8080' : 'https://myServer/';
After your app get published on App Store it will communicate with remote server.

How to connect my React app to a backend with which is different origin

Hello Experts
My problem is I am developing a react js application with some Axios call, I am connecting my serverside backend (which is an indifferent location like a real IP address) with writing a proxy in package.json which is working on my pc is fine,
But when I am going to deploy my application on AWS in production mode, unfortunately, the backend is not connecting (Maybe proxy is not working as I learn by google search ), in this situation what should I do to connect my react js app with my backend
please help me if you can thanx in advanced
Usually browsers block cross-origin request by default.
Please check cors npm package to whitelist/allow requests from your react app to backend server.
link: https://www.npmjs.com/package/cors
Hope this helps. :)

Resources