Is it posible integrate Socket.io with AWS Websockets Api Gateway? - node.js

I have a Socket.io angular-client and nodejs-Server, when I connect directly there is not problem, but when I'm trying to use the AWS websocket api gateway it is not possible.
I deployed an EC2 instance to run the Socket.io server and in my laptop de Socket.io client with the example proposed here. On direct connection everything works correctly but when I use the AWS Websockets Api Gateway it returns me
engine.io-client:socket socket error [Circular] +858ms
I implemented the route $connect as follows:
where ip_address corresponds to the public ip o f the EC2, I've also tried without the /socket.io, but nothing is working.
Am I miss configuring something in the route/integration? Or is not this the right way to work with socket.io and websockets api gateway

Related

Connect http API to https domain on AWS

I have a Web App with registered domain and it is running on AWS EC2. The domain is https:\\abc.abc. I have a flask API on the same instance where it running as a microservice. The API is running as http:\\abc.abc. Now when I try to connect to the API using the Web App with the registered domain it shows me
ERR_SSL_PROTOCOL_ERROR.
I have an idea that this is error is because of the
https and http connection
but I don't know how to solve it. Can someone please help?
In need for a somewhat detailed answer as this error is completely new for me.

Can we listen to changes in AWS API Gateway?

I have an API Gateway on AWS that returns some remote variables to the backend of my native application. The backend is built over NodeJS. Now, once in a while the values of these remote variables can change. Currently, in the nodeJS server, I make the API call at the start of the server and set the remote variables. However, at the moment, whenever I change the response I need to restart the server for the changes to propagate. Is there a way that I can listen for updates to the AWS API Gateway in my NodeJS running server? The documentation has not helped me so far.

Socket.IO service with API Gateway technic

I'm using microservices technic with node js and express, i used API Gateway(node js service that support https) that transfer the api requests to the other services, also i'm using SocketIO as a node js service.
I would like to know what will be the best way to securely connect to the socket IO service from the client if i used API Gateway technic.
There is two approach that i'm considered:
Use the socketIO service as a independent service without go through from API Gateway.
some way to transfer from API Gateway to socketIO service
Any advise from someone that solved this case?

socket.io on AWS EC2 Instance

I have an express node server running that is a backend for a REST API and a Websockets (for chatting feature) while my client is React.js
When I deploy my server to an AWS EC2 instance with security groups set up, I am able to make http api calls, but my socket.io connection doesn't work. I have tested the server locally on my localhost, which works.
I think this does something with the proxy in the package.json because testing locally when I change the proxy to my EC2 instance public ip while keeping my socket.io connection connected to my localhost it does not work.
I am not getting any "connection refused" errors.
So my question is how does the react.js proxy effect the socket.io connection?

Connect nodeJs app to on-premise server using Secure Gateway

I'm trying to connect from a nodejs webapp to a REST api hosted on premise. I bounded a Secure Gateway instance and created a destination on port 80 to the machine where the SG client for RHEL 6 is running.
The request is still throwing a Timeout exception.
Do I have to modify the nodejs application code in any way or the SG should allow me to access the REST api transparently?
Your Node.js app needs to talk to the Secure Gateway service and not the API directly. Where you establish a connection to your on-premise API, replace the host name and port number with the cloud host name and port number that you were given when you created the destination.
There is an npm module to help your app obtain that host name and port - https://www.npmjs.com/package/bluemix-secure-gateway
And an example - https://www.ibm.com/blogs/bluemix/2015/04/reaching-enterprise-backend-bluemix-secure-gateway-via-sdk-api/

Resources