Page 1 of 1

requests.post from linux to windows

Posted: Wed 22 Jun 2022 6:42 pm
by watsonm
I appreciate this is more likely to be a network problem but just in case someone has come across it before I'll post it here. I am more a windows man than linux so it could be a configuration problem.

I have a raspbery pi running cumulusmx and a python program on the same device posting my sensor data using the following code

Code: Select all

          try:      
                 x = requests.post( CMX_url , weather_data, timeout = 1.5)
                 y = x.text.find('success')
             
                 if y != 1 :
                    log_err("Ecowitt http output  failed ############# : ")
          except:
                 print("Failed")

where :
CMX_url = "http://localhost:8998/station/ecowitt"
weather_data={'dateutc' : EW_time , 'solarradiation' : LuxW, 'uv' : UV , ..... }

This works fine and if I copy the same code to my Windows box which also has CMX running and run it there it works fine.

Also if I change localhost to the appropriate 192.168.1.x it works fine on both boxes.
Both machines are on my local network with the same network mask.

What fails is if I run the code on the linux box but want to post to the WIndows box.
The command just times out no matter how long I make the timeout.
It doesn't evene execute the find command for "success" but drops straight to the except:

The command works fine from windows to linux!!
There are no obvious errors in the MXdiags file.
I can ping from linux to the windows box.

I have searched the internet but cannot find a solution or discover what I am missing so wonder if anyone has any bright ideas.

Edit: It must be a Linux network issue as http://192.168.1.2:8998 works on the window box but not in the browser of the linux box. However
on another tab in the linux browser I successfully get the CMX dashboard in if use the url http://192.168.1.15:8998

Re: requests.post from linux to windows

Posted: Thu 23 Jun 2022 6:04 am
by freddie
I'm a bit confused about which host has which IP address. If 192.168.1.15 works in a browser on your Linux box, does that mean your Windows box is using 192.168.1.15?

Re: requests.post from linux to windows

Posted: Thu 23 Jun 2022 7:35 am
by watsonm
Freddy,
sorry if it was not clear:

192.168.1.15 is a linux box
192.168.1.2 is the windows box

I can ping from linux to WIndows box.
I can get to the cmx desktop on the linux box from the linux box with 192.168.1.15:8998 in a browser
I can get to the cmx desktop on the windows box from the windows box with 192.168.1.2:8998 in a browser
I can get to the cmx desktop on the linux box from the windows box with 192.168.1.15:8998 in a browser
I cannot get to the cmx desktop on the windows box from the linux box with 192.168.1.2:8998

The same success or failure occurs with the request.post call.

I am a linux newbe so do not understand the network tables which I am assuming will hold the answer to my problem.
The browser in the linux box does seem to have difficulties getting to outside websites. Sometimes it works after a long time and sometimes
it times out.

Re: requests.post from linux to windows

Posted: Thu 23 Jun 2022 7:56 am
by rogerthn
watsonm wrote: Thu 23 Jun 2022 7:35 am Freddy,
sorry if it was not clear:

192.168.1.15 is a linux box
192.168.1.2 is the windows box

I can ping from linux to WIndows box.
I can get to the cmx desktop on the linux box from the linux box with 192.168.1.15:8998 in a browser
I can get to the cmx desktop on the windows box from the windows box with 192.168.1.2:8998 in a browser
I can get to the cmx desktop on the linux box from the windows box with 192.168.1.15:8998 in a browser
I cannot get to the cmx desktop on the windows box from the linux box with 192.168.1.2:8998

The same success or failure occurs with the request.post call.

I am a linux newbe so do not understand the network tables which I am assuming will hold the answer to my problem.
The browser in the linux box does seem to have difficulties getting to outside websites. Sometimes it works after a long time and sometimes
it times out.
If you have an other Windows box try to get the cmx desktop on the windows box from that, to exclude Windows FW blocking.

Re: requests.post from linux to windows

Posted: Thu 23 Jun 2022 8:43 am
by watsonm
Roger,
Thanks for that suggestion and pointer to WIndows FW.

The only other windows box is my wifes laptop which I am not permitted to fiddle with under pain of .....
Instead I tried to access 192.168.1.2:8998 from a browser on her laptop.
This failed so I added a rule in the windows firewall (which I had thought I had turned off as I use Emsisoft software to protect my PC) I had prevously disabled EMSIsoft protection with no improvement but the WIndows firewall rule addition did the trick. I could access the web page and also submit
the requests.post successfully.

Many thanks for your (and Freddys) time in helping with this.... :clap:

Re: requests.post from linux to windows

Posted: Thu 23 Jun 2022 11:13 am
by freddie
watsonm wrote: Thu 23 Jun 2022 8:43 am Many thanks for your (and Freddys) time in helping with this.... :clap:
I'm pretty sure I wasn't much help here :lol: but I was thinking Windows firewall rather then Linux networking, hence checking which IP address was which :D

Re: requests.post from linux to windows

Posted: Thu 23 Jun 2022 11:55 am
by rogerthn
watsonm wrote: Thu 23 Jun 2022 8:43 am Instead I tried to access 192.168.1.2:8998 from a browser on her laptop.
That's what I meant :D
watsonm wrote: Thu 23 Jun 2022 8:43 am Many thanks for your (and Freddys) time in helping with this.... :clap:
That's why we are here ;)