remote agent fails to connect with java.net.SocketException: Connection reset
Asked by winter wong:

Just use java -jar atlassian-bamboo-agent-installer-6.7.2.jar https://\<server\>/agentServer/ and find the issue.

INFO \| jvm 1 \| 2019/01/17 12:34:34 \| 2019-01-17 12:34:34,862 ERROR \[AgentRunnerThread\] \[AbstractFileCapabilityDefaultsHelper\] Cannot create capability for C:\\Program Files\\dotnet\\dotnet.exe  
INFO \| jvm 1 \| 2019/01/17 12:34:35 \| 2019-01-17 12:34:34,979 ERROR \[AgentRunnerThread\] \[AbstractFileCapabilityDefaultsHelper\] Cannot create capability for C:\\Program Files\\dotnet\\dotnet.exe  
INFO \| jvm 1 \| 2019/01/17 12:34:36 \| 2019-01-17 12:34:36,016 INFO \[AgentRunnerThread\] \[AgentRegistrationBean\] Registering agent on the server,  
INFO \| jvm 1 \| 2019/01/17 12:37:02 \| 2019-01-17 12:37:02,508 WARN \[ActiveMQ Transport: tcp://serverhost name/serverip:54663@50485\] \[FailoverTransport\] Transport (tcp://serverhost name:54663?wireFormat.maxInactivityDuration=300000) failed , attempting to automatically reconnect: java.net.SocketException: Connection reset


Answers:
author: Foong
body: The remote agent will try to connect to Bamboo server according to the setting "bamboo.jms.broker.client.uri" in the file **\<bamboo-server-home\>/bamboo.cfg.xml**

From the above error, try the following command in the machine hosting remote agent:

```
telnet?serverhost 54663
```

If it does not return the following example message, it means that machine hosting remote agent does not have network connection to the Bamboo server:

```
Trying ::1...
Connected to localhost.
Escape character is '^]'.
?ActiveMQ
         p
          TcpNoDelayEnabledSizePrefixDisabled CacheSize
                                                         ProviderName  ActiveMQStackTraceEnabledPlatformDetails KJVM: 1.8.0_73, 25.73-b02, Oracle Corporation, OS: Mac OS X, 10.12.6, x86_64
                            CacheEnabledTightEncodingEnabled
                                                            MaxFrameSize???MaxInactivityDuration?? MaxInactivityDurationInitalDelay'ProviderVersion 5.14.5
Connection closed by foreign host.
```

comments: author: winter wong
body: Thanks for quick reply. It does return message as you listed. But finally it shows connection lost. And I also tried the command on other work well agent, it shows the same return.

```
? ActiveMQ
?????????? {
????????????? TcpNoDelayEnabled SizePrefixDisabled ?? CacheSize
????????????????????????????????????????????????????????????????? ProviderName ActiveMQStackTraceEnabled PlatformDetails?????? VJVM: 1.8.0_192, 25.192-b12, Oracle Corporation, OS: Windows Server 2012 R2, 6.3, amd64
?????????????????????????????????????????????????????????????????????????????????????????????? CacheEnabled TightEncodingEnabled
??????????? MaxFrameSize ??? MaxInactivityDuration ?? MaxInactivityDurationInitalDelay ' ProviderVersion?????? 5.14.5

Connection to host lost.
```


author: Foong
body: During the remote agent startup, does it show the following example log message where it validate the URL?

```
2018-12-10 16:26:42,599 INFO [AgentRunnerThread] [BambooActiveMQConnectionFactory] Setting broker URL to 'failover:(tcp://serverhostname:54663?wireFormat.maxInactivityDuration=300000)?maxReconnectAttempts=10&initialReconnectDelay=15000'
2018-12-10 16:26:42,601 INFO [AgentRunnerThread] [BambooActiveMQConnectionFactory] Broker URI: tcp://serverhostname:54663?wireFormat.maxInactivityDuration=300000 is valid.

```

Is other remote agent that works well able to be restarted without problem?


author: winter wong
body: Thank you. I have solved it. The cause is firewall limitation. Just ask IT to open it.