I have tried to set up a deepstream.io instance but ran into some difficulties:
I don't know how to connect the deepstream.io instance to the rethinkdb server. I tried this condiguration:
//rethinkdb connector
server.set( 'storage', new RethinkDbConnector({
port: 28015,
host: '104.155.51.222',
splitChar: '/',
defaultTable: 'users'
}));
However, the server crashes after the start and puts out:
PLUGIN_ERROR | storage wasn't initialised in time
although I opend all the ports needet (8080 and 28015) and kept the instace running via tmux.
Do you have any idea how to fix this? I would really appreciate an answer, thanks in advance!
Stefan
Hm - looks like a connectivity issue between the machine that deepstream.io is running on and your RethinkDB machine. Just tried accessing 104.155.51.222:8080 in a browser and it timed out. Could you try
a) if you can access the admin gui
b) if you can ping 104.155.51.222 from your deepstream machine
Thanks for your answer! I was yersterday able to solve it by adding rethinkdb --bind all to the start command and using the eth0 adress to connect to it from the deepstream server.
However, there is now one more pressing issue I ran into: I am trying to connect the client-side sample code provided in the tutorial to a remote server who is already wired up for production. But once I connect to the server the chrome dev tools show something like this.
The deepstream server is running with the following configurations:
server.set( 'host', '0.0.0.0' );
server.set( 'port', 6020 );
Do you have an idea what went wrong? Anyways,thank you for your awesome work at deepstream.io, I really appreciate it!
Related
I am building an application using react.js and socket.io, I have my backend code for the socket.io server in one folder and the client/ frontend react.js code in a separate folder. I have it set up to where the server is listening on local host:4000 and the client is listening on 3000, I have connected the front end and back end in my app.js using this line of code..
const socket = io.connect('http://localhost:4000');
I am curious as to what this means. does it mean that when I deploy my website that it will be hosting my server from my computer? Does it mean that it will be hosting the sockets from the client's computers? is the localhost:4000 used for testing purposes and will need to be changed later upon deployment of the website? If none of these are correct, any explanation would be greatly appreciated. If my code is fine the way it is and will not need to be changed upon deployment of my website, please let me know.
Thank you to anyone who can help!!!
does it mean that when I deploy my website that it will be hosting my server from my computer?
It means it will try to connect to a Socket.io server running on the same computer as the browser is running on.
This will usually fail. (Your development environment is an exception because you are running both browser and server on the same computer).
is the localhost:4000 used for testing purposes and will need to be changed later upon deployment of the website?
Yes.
Yes, you will need to change it when you deploy it to your site.
'http://localhost:4000' is an absolute reference meaning it will auto resolve to the localhost environment. It is also advisable to switch to https for a more secure connection.
I am trying to connect to my MS SQL database via node.js (Express), but the connection cannot be established. I have probably wrong configuration, but I have tried everything and nothing worked. I also enabled TCP/IP in configuration Manager.
Here is my JS code: https://snipboard.io/ufk49d.jpg
Here is one of my errors: https://snipboard.io/wyTbLi.jpg
When I add localhost or IP adress before SQLEXPRESS in server configuration, it thow this error: https://snipboard.io/RE6Xov.jpg
And also, I added new user and allow SQL auth and windows auth connection.
Thanks for your tips!
Can you put your machine name in server parameter?
server: 'YOUR_MACHINE_NAME\\SQLEXPRESS',
EDIT
I think the problem might be that the WebSocket connection does not go through the proxy node.js. How to authorize the connection of the WebSocket?
I have a web app hosted on a nodeJS server. On the same vm I also have a shiny serveur hosting an app. I use node to redirect traffic to port 3838 (shiny) when a somes URL are requested.
I use this code on node :
app.use('/the-shiny-app', proxy({target: 'http://localhost:3838', changeOrigin: true}));
With this setting everything works fine on the shiny app when I go on mydomain/the-shiny-app/* except when I try to run code in a code box.
When I try to run code I get this error on the chrome console :
Connection closed. Info: {"type":"close","code":4503,"reason":"The application unexpectedly exited","wasClean":true}
An example of what I mean by code box :
if I do not use node.js and I redirect the traffic (on OS level) from port 80 directly to 3838 everything works fine.
sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 3838
I do not know exactly what kind of exchange is made between the browser and the shiny server when we run code, but maybe the protocol used is blocked by node.js.
I found the problem. As Antony Gibbs said you need to setup a WebSocket upgrade. I'm using http-proxy-middleware you cans find the doc here : https://github.com/chimurai/http-proxy-middleware
I've been given a project that is using a Paho/MQTT client through Javascript to update a web page. The project starts an http server through python on localhost:8080 and then, when the webpage is loaded, a main.js script starts the client and runs the connect as shown below:
var client = new Paho.MQTT.Client("localhost",Number(8080),'0');
client.onConnectionLost = onConLost;
client.onMessageArrived = onMesArvd;
console.log("start connection...");
client.connect({onSuccess: onConnect});
The problem is that upon trying to connect the below error appears and the onConnect method does not appear to connect as a console.log does not appear:
WebSocket connection to 'ws://localhost:8080/mqtt' failed: Error during WebSocket handshake: Unexpected response code: 404
The code highlighted in red in the paho-mqtt.js is below:
new WebSocket(a, ["mqtt"])
I tried adding a mqtt file to the folder localhost is being run from but it only changes the response code (301 if a mqtt folder is present, 200 if a file).
Adding the mosquitto.conf that came with the project:
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
listener 1883
listener 8080
protocol websockets
I noticed it's not in the same folder as the paho/mqtt client but in ../dir2/setup/.
I've looked around but I haven't seen anyone with this issue so any help/guidance would be greatly appreciated. Thanks!
Thanks to Santosh Balaji for pointing me in the right direction on this one.
I believe I needed to install mosquitto on the pi and then change the mosquitto.conf file in the mosquitto install dir to the one provided by the project. After installing and confirming my conf was being used the js and Python connected without issue.
1) Is port 8080 occupied by other process before starting mqtt. Try to start your mosquitto with conf file. It will show up error if there is anything wrong with the start.
mosquitto -c mosquitto.conf
2) Try changing the port to 9001 as it is default port for using websockets in mqtt
I have problem with my app with Action Cable on Heroku:
WebSocket connection to 'ws://localhost:3000/cable' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
My production.rb:
config.action_cable.url = "wss://NAME.herokuapp.com/cable"
config.action_cable.allowed_request_origins = ['https://NAME.herokuapp.com', 'http://NAME.herokuapp.com']
I tried to specify the server in the cable.js as well:
#App ||= {}
App.cable = ActionCable.createConsumer("wss://NAME.herokuapp.com/cable")
I tried to change it in development.rb just in case but nothing helps. The Heroku is still trying to connect to localhost.
Another weird thing that has nothing in common with it I think, is that the app is not able to process some js code like: alert('test') or console.log("haha") despite of some js code works and I tried assets:precompile as well.
In localhost, everything works perfectly. Any idea what can be wrong with heroku and the setting?
While ActionCable was in development, I remember you had to startup 2 servers for the cable connection and for Rails. I don't think that is still needed for the final release.
My guess is that you don't have Redis provisioned on your Heroku instance, whereas in Production, ActionCable relies on Redis for it's server communication.
To fix this, you should do the following:
heroku addons:add redistogo
heroku config | grep REDISTOGO_URL
In your config/cable.yml, set the Redis url to the one given. I guess you should also be able to use ENV['REDISTOGO_URL'] in place of the url.
Let me know if that helps.
If it's working locally but not remotely it may be an SSL problem. Make sure you properly set up an SSL endpoint for the secure websocket (wss):
https://devcenter.heroku.com/articles/ssl-endpoint
Also, there is an excellent blog post on Heroku about how to set up Action Cable: https://blog.heroku.com/real_time_rails_implementing_websockets_in_rails_5_with_action_cable. Alas, the article does not mention the necessity of setting up an SSL endpoint for the Heroku deployment to work.