mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
This happens sometimes, and the latest occurence was today: https://github.com/nats-io/java-nats/issues/96 When it happens, there is no error but subscribers would not receive anything, etc... This PR uses the fact that clients set the field Lang in the CONNECT protocol that ROUTEs do not. I have checked that all Apcera supported clients do set Lang in the CONNECT protocol. If we plan to add Lang for routes, we need to find another field or use a new one, in which case that would work only for new clients (that would need to be updated). With this change, when the server accepts a connection on the route port and detects that this protocol field is present, it now closes the client connection. The nice thing is that newer clients, when incorrectly connecting to the route port, get from the route's INFO the list of client URLs, which means that on the initial connect error, they are able to subsequently connect to the proper client port, so it is transparent to the user (which may or may not be a good thing). However, it is not guaranteed because if the client is not setting NoRandomize to true, the client URL is added but the array shuffled, so it is possible that the client library does not find the correct port in the connect loop.
37 lines
1.5 KiB
Go
37 lines
1.5 KiB
Go
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
|
|
|
package server
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
// ErrConnectionClosed represents an error condition on a closed connection.
|
|
ErrConnectionClosed = errors.New("Connection Closed")
|
|
|
|
// ErrAuthorization represents an error condition on failed authorization.
|
|
ErrAuthorization = errors.New("Authorization Error")
|
|
|
|
// ErrAuthTimeout represents an error condition on failed authorization due to timeout.
|
|
ErrAuthTimeout = errors.New("Authorization Timeout")
|
|
|
|
// ErrMaxPayload represents an error condition when the payload is too big.
|
|
ErrMaxPayload = errors.New("Maximum Payload Exceeded")
|
|
|
|
// ErrMaxControlLine represents an error condition when the control line is too big.
|
|
ErrMaxControlLine = errors.New("Maximum Control Line Exceeded")
|
|
|
|
// ErrReservedPublishSubject represents an error condition when sending to a reserved subject, e.g. _SYS.>
|
|
ErrReservedPublishSubject = errors.New("Reserved Internal Subject")
|
|
|
|
// ErrBadClientProtocol signals a client requested an invalud client protocol.
|
|
ErrBadClientProtocol = errors.New("Invalid Client Protocol")
|
|
|
|
// ErrTooManyConnections signals a client that the maximum number of connections supported by the
|
|
// server has been reached.
|
|
ErrTooManyConnections = errors.New("Maximum Connections Exceeded")
|
|
|
|
// ErrClientConnectedToRoutePort represents an error condition when a client
|
|
// attempted to connect to the route listen port.
|
|
ErrClientConnectedToRoutePort = errors.New("Attempted To Connect To Route Port")
|
|
)
|