No Response from WebSocket API

Hello,

I seem to be having a strange problem with the websocket API.  I can open the socket, and obtain statuses using recv(), but when I try to send any command (ping, listPrinter, etc.) I get no response from the server.

Any idea how I can start troubleshooting?

Comments

  • Use our gui with open debug tools. Go to network and search for socket and take latest one. Watch frames we send and receive. Then execute something requiring the call you want. Then you see how it looks correctly and what you get. 

    Then do same in your app and compare what is missing. E.g. did you authenticate user? Did you send printer slug? The difference and stream debugging normally shows the problem.

  • Thanks for the help.  It ended up being an encoding issue.  Once I started encoding the messages correctly I started getting responses immediately.  I did this in the following way in python (for those who come later):

    from websocket import create_connection
    import json

    TEST_PAYLOAD = {"action":"ping", "data":{}, "printer":"", "callback_id":0}

    ws= create_connection("ws://<IP>:3344/socket?apikey="+API_KEY)

    ws.send(json.dumps(TEST_PAYLOAD).encode())
    res = ws.recv()
    print(res)


Sign In or Register to comment.