Pages: [1]   Go Down
Author Topic: Check the status of a server script  (Read 1144 times)
0 Members and 1 Guest are viewing this topic.
London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a server running two python scripts that accept data from the arduino over ethernet through UDP packets.
What I want to do is have the arduino check whether they python scripts are running and therefore decide whether or not to send the data.
Any suggestions?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Two kinds of people can answer your question. Arduino/ethernet programmers or server programmers. Have you tried both.

I am not either of them so this is all I can say: do you get any response from your scripts to Arduino. Can you make them give a response. Or make a new one.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why do you wanna do that? You're sending UDP packets, almost any check for the scripts to be running will use more network resources than just sending the packets anyway. If nobody is listening for UDP packets, why do you care?

If you really do care: Implement on both sides heartbeat packets, just delivering the information that the program is alive. That way the Arduino can send such a packet and just sends data if it gets a response from the script.
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3447
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with above, why bother checking?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In theory you're right. I guess he's using that on his LAN. Have you seen a UDP packet dropping accidentally on your LAN? If the LAN is crowded like that he doesn't have to send any data either (using UDP).
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Basically if the arduino doesn't have an internet connection it will save any data to the SD card, but if it has internet it will send it to the server.  I want to implement this as a failsafe in case of a server crash I will not lose any data. 
I like the sound of the heartbeat packets but the devices will be rolled out in a large scale to multiple networks that don't necessarily have fixed IPs so how would I send packets to all the devices?

What I was hoping for was a way for the device to check on the server and then act accordingly.

The problem with TCP is that I don't want it to be blocking.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you relay on the data being sent via UDP you should always send back a confirmation packet. How do you know your data was received on the server? Maybe you should better use TCP connections, they're easier to handle for the beginner.

The heartbeat packets would be sent by the Arduino and the server is answering. If you can send the data to the server you should also be able to send a heartbeat packet. Also, the server should be able to respond to a simple packet received from the Arduino by sending a response.

Why is TCP blocking in any way? It's just a reliable connection.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you recommend any tcp libraries?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For Arduino? Use the same as for UDP. Depends on your hardware.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the arduino I am using the w5200 ethernet module, (exactly the same as the w5100)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
On the arduino I am using the w5200 ethernet module, (exactly the same as the w5100)
No, it isn't. There are significant differences between the two chips.

Support for TCP is built into the W5100 and W5200 chips, though.
Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3447
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the arduino I am using the w5200 ethernet module, (exactly the same as the w5100)
Check out the Web Server/Client libraries. They show you how to use TCP by implementing HTML within it.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I figured it out!
I have the scripts on the server creating their own http server instance and then the devices use act as a client, if they get a 200 when they try and access the webpage it knows its running.
If the script crashes so does that instance of the web server
Logged

Pages: [1]   Go Up
Jump to: