#1235  Issues creating a remote agent
Closed
dopel opened 1 year ago

While creating an docker agent in a remote machine, using the generated command:

docker run -t -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/agent/work:/agent/work -e serverUrl=https://subdomain.domain.tld -e agentToken=******-agent***token************ -h myagent 1dev/agent

...I am receiving the following error in the container logs:

Java Service Wrapper Standard Edition 64-bit 3.5.51
  Copyright (C) 1999-2022 Tanuki Software, Ltd. All Rights Reserved.
    http://wrapper.tanukisoftware.com
  Licensed to OneDev for Service Wrapping

Launching a JVM...
WrapperManager: Initializing...
21:33:30 INFO  io.onedev.agent.Agent - Connecting to https://subdomain.domain.tld...
21:33:30 INFO  io.onedev.agent.Agent - Connecting to https://subdomain.domain.tld...
21:33:31 ERROR io.onedev.agent.AgentSocket - Websocket error
org.eclipse.jetty.websocket.api.UpgradeException: Failed to upgrade to websocket: Unexpected HTTP Response Status Code: 405 Method Not Allowed
        at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:537)
        at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:218)
        at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:210)
        at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:481)
        at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:461)
        at org.eclipse.jetty.client.HttpReceiver.responseSuccess(HttpReceiver.java:424)
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.messageComplete(HttpReceiverOverHTTP.java:365)
        at org.eclipse.jetty.http.HttpParser.parseFields(HttpParser.java:1180)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1553)
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:204)
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:144)
        at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:79)
        at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:131)
        at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:172)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
        at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:555)
        at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:410)
        at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:164)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
        at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:137)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
        at java.base/java.lang.Thread.run(Thread.java:829)

However, when running the same in the same machine the said error doesn't occur. I've also tried to create agents in different machines & tried regenerating the agent token as well to no avail.

dopel changed fields 1 year ago
Name Previous Value Current Value
Priority
Normal
Major
Robin Shen commented 1 year ago

Make sure you've configured websocket forwarding in your reverse proxy as described here:

https://docs.onedev.io/administration-guide/reverse-proxy-setup

dopel commented 1 year ago

Thanks for sharing that @robin

I am using Nginx Proxy Manager as a GUI-based reverse proxy. The mistake I made was specifying the following in the global configuration instead for the specific location:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Its resolved now & working as expected.

Robin Shen changed state to 'Closed' 1 year ago
Previous Value Current Value
Open
Closed
issue 1 of 1
Type
Bug
Priority
Major
Assignee
Affected Versions
Not Found
Issue Votes (0)
Watchers (4)
Reference
onedev/server#1235
Please wait...
Page is in error, reload to recover