Sorry for such basic questions but obviously my knowledge of both SignalK and Python is limited
.
I have managed to connect to SignalK with the following:
import websocket
ws = websocket.WebSocket()
ws.connect("ws://localhost:3000/signalk/v1/stream")
print(ws.recv())
ws.close()
This returns:
{"name":"signalk-server","version":"1.37.6","self":"vessels.urn:mrn
ignalk:uuid:1a221f54-3677-4260-ab71-cbd99552f5a4","roles":["master","main"],"timestamp":"2021-02-10T18:33:13.731Z"}
My next problem - What is the correct url to get all the data streaming?
When readings the docs on signalK it says
- ws://hostname/signalk/«version»/stream?subscribe=all
However when I try
import websocket
ws = websocket.WebSocket()
ws.connect("ws://localhost/signalk/v1/stream?subscribe=all")
print(ws.recv())
ws.close()
I get errors as below:
raceback (most recent call last):
File "/home/pi/Python/Test2.py", line 4, in <module>
ws.connect("ws://localhost/signalk/v1/stream?subscribe=all")
File "/usr/lib/python3/dist-packages/websocket/_core.py", line 219, in connect
options.pop('socket', None))
File "/usr/lib/python3/dist-packages/websocket/_http.py", line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "/usr/lib/python3/dist-packages/websocket/_http.py", line 190, in _open_socket
raise err
File "/usr/lib/python3/dist-packages/websocket/_http.py", line 170, in _open_socket
sock.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused
I seem to have an error in ws.connect("ws://localhost/signalk/v1/stream?subscribe=all")
What is the correct format?
Thanks, Jodel