Observed behavior
As the title says, when I call nats.Connect using an expired (or about to) JWT token, the function returns EOF instead of nats.ErrAuthorization or nats.ErrAuthExpired
I did a traffic analysis with WireShark and I can see the server INFO and also the -ERR 'Authorization Violation' message.
I can also see the websocket close frame the server sends with Authentication Failure and the client response.
The issue happens in Conn.sendConnect. connectProto and writeDirect calls succeedes but the nc.readProto call fails with EOF because, at the time it executes, the connection is closed, and the -ERR message was also consumed in the natsReader object (off == -1 and you can see the message still in the buffer array)
If there is a way to get the close frame reason, I don't know.
Expected behavior
To return the proper error.
Server and client version
Client: 1.48.0
Host environment
Client: Microsoft Windows
Server: AWS Linux
Steps to reproduce
Just connect to a server with a valid but expired token using websocket protocol.
Observed behavior
As the title says, when I call
nats.Connectusing an expired (or about to) JWT token, the function returns EOF instead ofnats.ErrAuthorizationornats.ErrAuthExpiredI did a traffic analysis with WireShark and I can see the server
INFOand also the-ERR 'Authorization Violation'message.I can also see the websocket close frame the server sends with
Authentication Failureand the client response.The issue happens in Conn.sendConnect. connectProto and writeDirect calls succeedes but the nc.readProto call fails with
EOFbecause, at the time it executes, the connection is closed, and the-ERRmessage was also consumed in thenatsReaderobject (off == -1and you can see the message still in the buffer array)If there is a way to get the close frame reason, I don't know.
Expected behavior
To return the proper error.
Server and client version
Client: 1.48.0
Host environment
Client: Microsoft Windows
Server: AWS Linux
Steps to reproduce
Just connect to a server with a valid but expired token using websocket protocol.