Tomcat 和 Guacamole(guacd) 服务器之间的连接被拒绝 - Apache Guacamole

Connection refused between Tomcat and Guacamole(guacd) server - Apache Guacamole

前段时间我在我的 LAMP 服务器,安装很简单,因为说明清晰易懂,无论 RDP、SSH 还是 VNC,Guacamole 实例都能完美运行。

昨天我遇到了鳄梨酱的问题 - 从前端开始:

An internal error has occurred within the Guacamole server, and the connection has been terminated. If the problem persists, please notify your system administrator, or check your system logs.

所以问题表明 Guacamole 服务器单独存在问题,读取 Guacamole 的状态:

maj 20 10:02:02 mywebsite.here systemd[1]: Starting LSB: Guacamole proxy daemon...
maj 20 10:02:02 mywebsite.here guacd[32305]: Guacamole proxy daemon (guacd) version 1.4.0 started
maj 20 10:02:02 mywebsite.here guacd[32303]: Starting guacd:
maj 20 10:02:02 mywebsite.here guacd[32305]: guacd[32305]: INFO:        Guacamole proxy daemon (guacd) version 1.4.0 started
maj 20 10:02:02 mywebsite.here guacd[32307]: Listening on host ::1, port 4822
maj 20 10:02:02 mywebsite.here guacd[32303]: SUCCESS
maj 20 10:02:02 mywebsite.here systemd[1]: Started LSB: Guacamole proxy daemon.

从 guacd 的当前日志看来一切正常,guacd 侦听本地主机并绑定到 4822 - 检查 netstat 以验证服务可用性:

tcp6       0      0 localhost:4822          [::]:*                  LISTEN      32307/guacd

然后远程登录到 localhost:4822 :

    telnet localhost 4822
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.

按下回车键

Connection closed by foreign host.

回到鳄梨酱:

guacd[32307]: Guacamole protocol violation. Perhaps the version of guacamole-client is incompatible with this version of guacd?

因为您不能将 telnet 与鳄梨酱一起使用,所以连接已终止,但据我所知,该服务可用且可以使用。

由于鳄梨酱看起来不错,现在是 Tomcat9 的时候了:

[2022-05-20 10:20:26] [info] 10:20:26.434 [http-nio-8080-exec-10] ERROR o.a.g.w.GuacamoleWebSocketTunnelEndpoint - Creation of WebSocket tunnel to guacd failed: java.net.ConnectException: Połączenie odrzucone (Connection refused)
[2022-05-20 10:20:26] [info] 10:20:26.682 [http-nio-8080-exec-8] ERROR o.a.g.s.GuacamoleHTTPTunnelServlet - HTTP tunnel request failed: java.net.ConnectException: Połączenie odrzucone (Connection refused)

越来越清楚问题必须在 Tomcat9 和鳄梨酱本身之间以及 Tomcat 方面 - 你有什么想法如何调试它吗?

Tomcat 增加日志级别的日志:

错误时刻:

    [2022-05-24 08:56:11] [info] 08:56:11.135 [http-nio-8080-exec-3] DEBUG o.a.i.d.pooled.PooledDataSource - Testing connection 29049410 ...
    [2022-05-24 08:56:11] [info] 08:56:11.139 [http-nio-8080-exec-3] DEBUG o.a.i.d.pooled.PooledDataSource - Connection 29049410 is GOOD!
    [2022-05-24 08:56:11] [info] 08:56:11.139 [http-nio-8080-exec-3] DEBUG o.a.i.d.pooled.PooledDataSource - Returned connection 29049410 to pool.
    [2022-05-24 08:56:11] [info] 08:56:11.140 [http-nio-8080-exec-3] ERROR o.a.g.w.GuacamoleWebSocketTunnelEndpoint - Creation of WebSocket tunnel to guacd failed: java.net.ConnectException: Połączenie odrzucone (Connection refused)
    [2022-05-24 08:56:11] [info] 08:56:11.159 [http-nio-8080-exec-3] DEBUG o.a.g.w.GuacamoleWebSocketTunnelEndpoint - Error connecting WebSocket tunnel.
    [2022-05-24 08:56:11] [info] org.apache.guacamole.GuacamoleServerException: java.net.ConnectException: Połączenie odrzucone (Connection refused)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.net.InetGuacamoleSocket.<init>(InetGuacamoleSocket.java:114)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.auth.jdbc.tunnel.ManagedInetGuacamoleSocket.<init>(ManagedInetGuacamoleSocket.java:56)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.auth.jdbc.tunnel.AbstractGuacamoleTunnelService.getUnconfiguredGuacamoleSocket(AbstractGuacamoleTunnelService.java:319)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.auth.jdbc.tunnel.AbstractGuacamoleTunnelService.assignGuacamoleTunnel(AbstractGuacamoleTunnelService.java:483)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.auth.jdbc.tunnel.AbstractGuacamoleTunnelService.getGuacamoleTunnel(AbstractGuacamoleTunnelService.java:643)
    [2022-05-24 08:56:11] [info] #011at org.mybatis.guice.transactional.TransactionalMethodInterceptor.invoke(TransactionalMethodInterceptor.java:96)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.auth.jdbc.connection.ConnectionService.connect(ConnectionService.java:548)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.auth.jdbc.connection.ModeledConnection.connect(ModeledConnection.java:274)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.tunnel.TunnelRequestService.createConnectedTunnel(TunnelRequestService.java:216)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.tunnel.TunnelRequestService.createTunnel(TunnelRequestService.java:347)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.tunnel.websocket.RestrictedGuacamoleWebSocketTunnelEndpoint.createTunnel(RestrictedGuacamoleWebSocketTunnelEndpoint.java:113)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint.onOpen(GuacamoleWebSocketTunnelEndpoint.java:200)
    [2022-05-24 08:56:11] [info] #011at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:136)
    [2022-05-24 08:56:11] [info] #011at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:934)
    [2022-05-24 08:56:11] [info] #011at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)
    [2022-05-24 08:56:11] [info] #011at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    [2022-05-24 08:56:11] [info] #011at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    [2022-05-24 08:56:11] [info] #011at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    [2022-05-24 08:56:11] [info] #011at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    [2022-05-24 08:56:11] [info] #011at java.base/java.lang.Thread.run(Thread.java:829)
    [2022-05-24 08:56:11] [info] Caused by: java.net.ConnectException: Połączenie odrzucone (Connection refused)
    [2022-05-24 08:56:11] [info] #011at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
    [2022-05-24 08:56:11] [info] #011at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
    [2022-05-24 08:56:11] [info] #011at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
    [2022-05-24 08:56:11] [info] #011at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
    [2022-05-24 08:56:11] [info] #011at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    [2022-05-24 08:56:11] [info] #011at java.base/java.net.Socket.connect(Socket.java:609)
    [2022-05-24 08:56:11] [info] #011at org.apache.guacamole.net.InetGuacamoleSocket.<init>(InetGuacamoleSocket.java:100)
    [2022-05-24 08:56:11] [info] #011... 19 common frames omitted

我不喜欢 Java 无论如何,但我相信实际的错误原因在日志的那部分。如果与 Java 相关的任何人查看并提供他们的意见,我将不胜感激。

Guacamole.properties:

MySQL properties 
mysql-hostname: 127.0.0.1 
mysql-port: 3306 
mysql-database: guacamole_db 
mysql-username: guacamole_admin
mysql-password: guacamole_******
Hostname and port of guacamole proxy 
guacd-hostname: 192.168.1.49
guacd-port:     4822

localhost 表示之间的更改 (127.0.0.1/::1/localhost/192.168.1.49[local static addr]) 不会产生差异

分析 Apache 日志可能毫无意义,因为通过 Tomcat9 尝试使用鳄梨酱只会提供相同的结果。

我已设法解决问题 - 此实例失败的原因是 guacd.conf 文件的 non-existence,该文件应基于 /etc/guacamole 本地化,绑定到 ::1无论我多么努力地尝试,都无法正常工作 - 绑定到 IPv4 表示 [127.0.0.1] 有效 - 检查我所有用户的历史记录以验证文件的删除,但没有找到任何东西。奇怪。

为了避免再次发生这种情况,我最好的建议是跟踪您当前的配置文件,以便根据需要轻松重新配置,并了解有关配置文件结构的一般知识。