How can I debug a connection issue within VOLTTRON?
Question: I am connecting to an external VOLTTRON instance. I am not getting a response
from the connection. What's the issue?

I am writing a simple python script to connect to an external platform and
retrieve the peers. If I get the serverkey, clientkey, and/or publickey
incorrect I don't know how to determine which is the culprit, from the client
side. I just get a gevent timeout. Is there a way to know?

    
    
    import os
    
    import gevent
    from volttron.platform.vip.agent import Agent
    
    secret = "secret"
    public = "public"
    serverkey = "server"
    tcp_address = "tcp://external:22916"
    
    agent = Agent(address=tcp_address, serverkey=serverkey, secretkey=secret,
                  publickey=public)
    event = gevent.event.Event()
    greenlet = gevent.spawn(agent.core.run, event)
    event.wait(timeout=30)
    print("My id: {}".format(agent.core.identity))
    peers = agent.vip.peerlist().get(timeout=5)
    for p in peers:
        print(p)
    gevent.sleep(3)
    greenlet.kill()
    


Answer: The short answer: no, the client cannot determine why its connection to the
server failed. The client will attempt to connect until it times out.

Logs and debug messages on the _server side_ can help troubleshoot a
connection problem. There are three distinct messages related to key errors:

  1. `CURVE I: cannot open client HELLO -- wrong server key?`  
Either the client omit the server key, the client used the wrong server key,
or the server omit the secret key.

  2. `CURVE I: cannot open client INITIATE vouch`  
Either the client omit the public or secret key, or its public and secret keys
don't correspond to each other.

  3. `authentication failure`  
The server key was correct and the secret and public keys are valid, but the
server rejected the connection because the client was not authorized to
connect (based on the client's public key).

The first two messages are printed by
[libzmq](https://github.com/zeromq/libzmq/blob/master/src/curve_server.cpp).
To see the third message `volttron` must be started with increased verboseness
(at least `-v`).

