diff --git a/server/client.go b/server/client.go
index <HASH>..<HASH> 100644
--- a/server/client.go
+++ b/server/client.go
@@ -310,23 +310,28 @@ func (c *client) processConnect(arg []byte) error {
 	c.mu.Lock()
 	c.clearAuthTimer()
 	c.last = time.Now()
+	typ := c.typ
+	r := c.route
+	srv := c.srv
 	c.mu.Unlock()
 
 	if err := json.Unmarshal(arg, &c.opts); err != nil {
 		return err
 	}
 
-	if c.srv != nil {
+	if srv != nil {
 		// Check for Auth
-		if ok := c.srv.checkAuth(c); !ok {
+		if ok := srv.checkAuth(c); !ok {
 			c.authViolation()
 			return ErrAuthorization
 		}
 	}
 
 	// Grab connection name of remote route.
-	if c.typ == ROUTER && c.route != nil {
+	if typ == ROUTER && r != nil {
+		c.mu.Lock()
 		c.route.remoteID = c.opts.Name
+		c.mu.Unlock()
 	}
 
 	if c.opts.Verbose {
Fix data race

When processing a connect request, there was a risk of race condition
when the server was being shutdown. Capture fields that are checked
under lock and lock when setting the route's remote ID.

Resolves #<I>