how to implement a TCP socket in serverSocket.cpp ?
-
@eberlin Another idea is to make a connection from your PC to the Duet, with a tool like discussed in
https://stackoverflow.com/questions/4797534/how-do-i-manually-fire-http-post-requests-with-firefox-or-chrome
and send the http requests from inside your browser. You need to have the Wifi connected to your Duet (if you use DWC with this PC, this is fulfilled). Instead of the hostname you can use the IP address of Duet in most cases.E.g. postman seems a good tool (I don't know it).
-
thanks for your ideas
@danal @JoergS5
my goal is to send the current printer status to my nodejs server. the server runs on a cloud server.
the server app should deliver a website with the printer status and some buttons to control the printer.
the website on the server should have the same functionality's as the DWC from chrishamm.
to use the DWC i need to connect my "Duet Wifi" with my router and after that , every PC in the local network can reach the website. but the nodejs server cant reach the local IP of the duet board, after the printer succcenfully connects to the router. i'am searching for a general solution to control numerous duet printer. and my plan is, that the printer sends the request, to open a socket to the server.the server should manage multiple tcp sockets to different duet wifi printer.
use case:
the user can control the printer over the internet, for example "start print" or "stop print".use case:
the user can check the current status of the printer over the internet.@JoergS5
i can't Serial.println my steps, because the ESP8266-modul is connected to the duet board. i didn't get any response because the firmware dont any message trough..the only idea i had, was to buy an esp8266 modul and write there the code. after i tested the code at this seperate modul , i was sure that the code is correct and copied it in the right place of the SocketServer.cpp
-
@eberlin One thing to start with is how to handle the internet connection for your Duet to the internet and from the internet.
Please search for internet in the forum, you will find some threads how to connect and how to protect, e.g.
https://forum.duet3d.com/topic/6746/secure-your-printers-before-it-s-too-late/19
https://forum.duet3d.com/topic/6064/acces-duetwifi-from-the-internet
https://forum.duet3d.com/topic/4283/what-not-to-spend-time-resource-developingThere is a tool here to monitor several printers, you may want to look at this also.
https://forum.duet3d.com/topic/6351/printer-farm/2
The MutliDuetWebMonitor, I think it's from @Danal :
https://github.com/DanalEstes/MultiDuetWebMonitor -
multiDuetWebmonitor is nice, but it's also cannot connect to the printer over the internet. he can reach the ip , if the PC is in the same network.
the links show tips to connect with VPN. i dont wont to use this way.
i know that the WifiModul on the Duet board is in general able to connect to server outside of the local network. but something in the DuetWifiSocketServer Firmware is blocking this way. i know that, because dc42 told me in a thread, that he does that.
he implemented a TCP socket in the SocketServer.cpp, but i dont know how..this is the best way to connect the printer with the server, because every user can use this without to prepare there router and so on ..
-
Thank you for describing what you are trying to do.
It is my very strong recommendation that your NodeJS server open the connection and "poll" the printer. I say this because:
-
NO CHANGES to Duet/RepRap firmware are required to do this. It can and will work instantly whenever you add code to your NodeJS server to perform this function.
-
At some level, you are trying to solve the "how do I connect the Duet/RepRap/Printer on my private network to my NodeJS server (presumably running in a 'cloud' data center somewhere) that is visible on the public internet.
Phrasing it that way makes it much more clear that no changes to the Duet/RepRap are required... getting that private/public connection to work is the munch more important piece.
Yet another way to phrase the same thing: You discovered that adding code to RepRap to open the connection didn't solve anything. It (mostly) not about who opens, or sends, or etc... it is about getting from one to the other.
-
-
So, what will work? You need:
-
Static IP or Dynamic DNS on your Home Network to ISP connection.
-
Static IP for the printer itself inside your Home Network.
-
A Reverse Proxy. Personally, I'd run this on a Raspberry Pi. There are lots of other ways.
There are tons of guides on the internet for the first three of the above things... just google...
-
Almost goes without saying... but just for clarity... security on that reverse proxy; security that keeps the bad guys out and lets your NodeJS in. I phrase it that way because picking what security you use is largely up to whatever you wish to code into NodeJS.
-
NodeJS to open the printer by the External IP (very first bullet above), connect, poll, etc. From the things you've already done, it looks like you have the skills, etc. If you need tips or get stuck, I'd be happy to help.
That's how I would do it...
-
-
This post is deleted! -
@eberlin you should follow the hints from @Danal how to open your router and address the internal Duet. If you send the TCP connection from your node.js to the Duet, this channel will be used to get the response back and should work through your router.
To open the router, it is good to restrict access to the server network MAC address where your node.js runs on, so nobody else can call in.
The Duet's Wifi is http only, no https. So traffic to or from Duet is not protected, Wifi passwords or other sensitive data could be spyed. That's the reason for the Raspberry solution. This was a separate Thread in the Duet forum.
Many years ago I used a different solution: an old PC, installed with two network cards, and a software called floppyfw on it. This allowed specified firewall rules with allowances and restrictions.
If the WifiSocketServer blocks something: do you know the thread so I can read and try to understand it?
-
@joergs5 said in how to implement a TCP socket in serverSocket.cpp ?:
Many years ago I used a different solution: an old PC, installed with two network cards, and a software called floppyfw on it. This allowed specified firewall rules with allowances and restrictions.
Exactly!
That's what the reverse proxy on the Pi will do...
-
status is the easy part. connect to duet with
http://a.b.c.d/rr_connect?password="xxx"&time="2018-04-09T21:46:00"
and then poll
http://a.b.c.d/rr_status?type=3I do that on my node-red server that provides a GUI with the status of a printer