This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OpenPlotter data to Python
#12
Sorry for such basic questions but obviously my knowledge of both SignalK and Python is limited Sad.
 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:mrnConfusedignalk: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


Reply


Messages In This Thread
OpenPlotter data to Python - by Jodel - 2021-02-06, 10:31 PM
RE: OpenPlotter data to Python - by PaddyB - 2021-02-07, 09:45 AM
RE: OpenPlotter data to Python - by Jodel - 2021-02-07, 06:28 PM
RE: OpenPlotter data to Python - by PaddyB - 2021-02-07, 09:17 PM
RE: OpenPlotter data to Python - by Jodel - 2021-02-07, 10:15 PM
RE: OpenPlotter data to Python - by PaddyB - 2021-02-07, 10:32 PM
RE: OpenPlotter data to Python - by Jodel - 2021-02-07, 11:40 PM
RE: OpenPlotter data to Python - by tkurki - 2021-02-08, 07:10 AM
RE: OpenPlotter data to Python - by Jodel - 2021-02-08, 12:42 PM
RE: OpenPlotter data to Python - by PaddyB - 2021-02-08, 04:21 PM
RE: OpenPlotter data to Python - by Sailoog - 2021-02-08, 08:30 PM
RE: OpenPlotter data to Python - by Jodel - 2021-02-10, 07:46 PM
RE: OpenPlotter data to Python - by Sailoog - 2021-02-10, 08:21 PM
RE: OpenPlotter data to Python - by Sailoog - 2021-02-10, 08:29 PM
RE: OpenPlotter data to Python - by Jodel - 2021-02-10, 09:18 PM
RE: OpenPlotter data to Python - by Hillzzz - 2023-12-18, 07:58 PM
RE: OpenPlotter data to Python - by PaddyB - 2023-12-19, 11:18 AM
RE: OpenPlotter data to Python - by DroZDi - 2024-01-11, 11:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)