mnetship / ratsio

NATS & NATS Streaming Server client library for Rust
MIT License
50 stars 22 forks source link

No auth on reconnect? #2

Closed d-e-s-o closed 4 years ago

d-e-s-o commented 5 years ago

Please check out the following trace:

[INFO  ratsio::net::connection]  Resolved XXX to YYY
[INFO  ratsio::net::connection]  Resolved XXX to YYY
[INFO  ratsio::net::connection]  Resolved XXX to YYY
[DEBUG ratsio::net::connection] Got a socket successfully.
[DEBUG ratsio::nats_client::client] Creating NATS client, got a connection.
[DEBUG ratsio::nats_client::client] Subscription for XXX / YYY
[DEBUG ratsio::codec]  Sending --->
CONNECT {"verbose":true,"pedantic":false,"tls_required":false,"auth_token":"XXX","lang":"rust","version":"0.2.0","protocol":1,"echo":true}
[DEBUG ratsio::codec]  Sending --->
SUB     XXX  YYY
[DEBUG ratsio::codec]  Op::Item => INFO(ServerInfo { ..., auth_required: true, tls_required: false, tls_verify: false, connect_urls: [] })
[DEBUG ratsio::codec]  Op::Item => OK
[DEBUG ratsio::codec]  Op::Item => OK
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::codec]  Sending --->
PING
[DEBUG ratsio::codec]  Op::Item => PONG
[DEBUG ratsio::nats_client::client]  Received PONG
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::codec]  Sending --->
PING
[DEBUG ratsio::codec]  Op::Item => PONG
[DEBUG ratsio::nats_client::client]  Received PONG
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::codec]  Sending --->
PING
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::nats_client::client] Skipped a ping.
[DEBUG ratsio::codec]  Sending --->
PING
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::nats_client::client] Skipped a ping.
[DEBUG ratsio::codec]  Sending --->
PING
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::nats_client::client] Skipped a ping.
[DEBUG ratsio::codec]  Sending --->
PING
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::nats_client::client] Skipped a ping.
[ERROR ratsio::nats_client::client] Pings are not responded to, we may be down.
[TRACE ratsio::net::connection] Trigger reconnection
[TRACE ratsio::net::connection] Reconnecting
[INFO  ratsio::net::connection]  Resolved XXX to YYY
[INFO  ratsio::net::connection]  Resolved XXX to YYY
[INFO  ratsio::net::connection]  Resolved XXX to YYY
[TRACE ratsio::net::connection] Retrying [...]
[DEBUG ratsio::net::connection] Got a socket successfully.
[DEBUG ratsio::net::connection] Got a connection
[DEBUG ratsio::codec]  Sending --->
SUB     XXX  YYY

[DEBUG ratsio::codec]  Op::Item => INFO(ServerInfo { ..., auth_required: true, tls_required: false, tls_verify: false, connect_urls: [] })
[DEBUG ratsio::codec]  Op::Item => ERR("Authorization Violation")
[ERROR ratsio::nats_client::client] NATS Server - Error - Authorization Violation
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::codec]  Sending --->
PING
[TRACE ratsio::nats_client::client]  Send PING
[DEBUG ratsio::nats_client::client] Skipped a ping.
[DEBUG ratsio::codec]  Sending --->
PING

What is seemingly happening is that we reconnect due to missed pings, but while we send authentication information (as part of the CONNECT) in the initial connect, we don't do so when reconnecting. Is this intentional?

gpeers commented 5 years ago

@d-e-s-o hiya, we're blocked by the issue as well. did you ever find a workaround?

d-e-s-o commented 5 years ago

Unfortunately no :-|

davidMcneil commented 5 years ago

See PR #3 for a fix.