COVESA / vissr

Mozilla Public License 2.0
6 stars 5 forks source link

csv_client.go #31

Closed petervolvowinz closed 7 months ago

petervolvowinz commented 7 months ago

Issue with menu and performNoneCommand is that the menu which is reading from command line and issuing unsubscribe reads from the same web socket connection while still in the performNonecommand loop, this one consumes the intended read response which lets us hanging in

  func getResponse(conn *websocket.Conn, request []byte) []byte {
    err := conn.WriteMessage(websocket.BinaryMessage, request)
    if err != nil {
        fmt.Printf("Request error:%s\n", err)
        return nil
    }
    _, msg, err := conn.ReadMessage()

However, the current code also writes the command q to the command number channel... we get

for {
        fmt.Scanf("%s\n", &commandNumber)
        if commandNumber == "q" {
            unsubReq := <-unsubChannel
            fmt.Printf("Unsubscribe request: %s\n", unsubReq)
            getResponse(conn, []byte(unsubReq))
        } 
        optionChannel <- commandNumber

    }

Which then is treated as command number, although handled it is a bit strange to instruct to use q and then issue an error message that this command is not supported. Suggestion to detect q and just roll with it ?

In some cases when we don't get stuck the server returns a web socket error:

Response error: websocket: RSV2 set, RSV3 set, bad opcode 4

Further more, forcefully killing an ongoing subscription such as menu number 5: {"action":"subscribe","filter":{"parameter":{"bufsize":"20","maxerr":"2"},"type":"curvelog"},"path":"Vehicle.Speed","requestId":"275"} , will put the server in endless error loop...

...
{"file":"serviceMgr.go:394","level":"info","msg":"deactivateSubscription: closeClSubId set to 1","time":"2024-04-25T10:57:28Z"}
vissv2server       | {"file":"serviceMgr.go:1184","level":"info","msg":"internal-killsubscriptions: RouterId = 1?0","time":"2024-04-25T10:57:28Z"}
vissv2server       | {"file":"serviceMgr.go:394","level":"info","msg":"deactivateSubscription: closeClSubId set to 1","time":"2024-04-25T10:57:28Z"}
vissv2server       | {"file":"serviceMgr.go:1184","level":"info","msg":"internal-killsubscriptions: RouterId = 1?0","time":"2024-04-25T10:57:28Z"}
vissv2server       | {"file":"serviceMgr.go:394","level":"info","msg":"deactivateSubscription: closeClSubId set to 1","time":"2024-04-25T10:57:28Z"}
...
petervolvowinz commented 7 months ago

there is a branch wscsv_client which fixes to the css_client is being done. The server issue should be done in a separate branch.

UlfBj commented 7 months ago

PR#33 fixes this (I believe?)