我正在做一个小项目,我正在尝试使用他们给我的 url 将 json 数据从传感器节点发送到服务器。它工作了几天,直到今天,它一直说('连接中止。',错误(110,'连接超时'))。我在同一个网络上有几个节点,它们都无法发送。我尝试使用不同网络和 ISP 上的节点将数据发送到服务器,并且成功。
我正在使用 pythonv2.7 并请求 lib 版本:2.4.3
这是代码:
import time
import requests
headers = {'content-type': 'application/json'}
url = 'http://czwxxx.org/pxxx_API/v1/node1'
MAC = "v0 v0 v0 v0 v0 v0"
time = int(round(time.time()*1000))
data = {"MAC":MAC,"time":time,"x_raw":'0',"y_raw":'0',"z_raw":'0','status':'1'}
requests.post(url,data=data)
这是回溯
sudo python test.py
Traceback (most recent call last):
File "test.py", line 11, in <module>
requests.post(url,data=data)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 94, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(110, 'Connection timed out'))
我尝试将 iptables 设置为接受所有流量,但无济于事。下面是输出
sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
检查 netstat -pn|grep :80 似乎卡在 SYN_SENT 并且没有收到回复?
sudo netstat -pn|grep :80
tcp 0 1 192.168.8.104:34856 166.62.28.86:80 SYN_SENT 13751/python
我不确定问题出在我的 Internet、节点配置还是防火墙上。我对此有点陌生。任何帮助将不胜感激。