X11从无头服务器到另一个X11服务器

发布于 2024-12-18 14:09:18 字数 320 浏览 5 评论 0原文

我有一个在无头服务器上运行的应用程序。它是一个 Web 应用程序,但对于某些功能(调试),它运行一个基于 swing 的应用程序。由于服务器是无头的(我已经设置了 -Djava.awt.headless=true),它在启动时抛出异常...

我尝试安装 Xvfb 但这并不能解决我的问题问题是 Xvfb 没有 GUI 输出,我看不到输出。

因此,我想将该服务器的输出重定向/转发到另一台服务器(例如我的笔记本电脑),以便查看 swing 应用程序并对其进行调试。

有没有办法使用 DISPLAY 变量或其他变量来实现它?

谢谢。

I have an application running on a headless server. It is a web application but for a certain feature (debugging) it runs a swing based application. As the server is headless (I already set the -Djava.awt.headless=true) it throws an exception when starting it up...

I've tried installing Xvfb but that wouldn't solve my problem as Xvfb doesn't have a GUI output and I couldn't see the output.

So I want to redirect/forward the output of that server to another one (for instance my laptop) in order to see the swing application and debug it.

Is there any way of achieving it using the DISPLAY variable or anything else?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故笙诉离歌 2024-12-25 14:09:18

如果你的笔记本电脑上运行着 X-server,你可以在 SSH 中启用 X-Forwarding 来 ssh 进入你的服务器,它会自动将你的 DISPLAY 变量设置为 :10.0 行中的内容,并且你可以使用 GUI 运行你的应用程序导出到本地 X 服务器。

否则,如果您想手动设置“显示”,则需要确保服务器可以通过 x 服务器端口上的直接 TCP 连接到达您的笔记本电脑。

If you have an X-server running on your laptop, you could ssh into your server with enabled X-Forwarding in your SSH, it will automagically set your DISPLAY variable to something in lines of :10.0 and you can run your application with GUI being exported to your local X-server.

Otherwise if you want to set DISPLAY manually you would need to make sure that server can reach your laptop with a direct TCP connection on x-server port.

八巷 2024-12-25 14:09:18

您可以

  1. 运行 Xvnc 并使用 VNC 客户端连接到它
  2. 运行 Xvfb 和 x11vnc 并使用 VNC 客户端连接到它(这与上面的不同,但最终结果是相同的;仅当您已经运行 Xvfb 时才有用)出于某些其他原因)
  3. 根据favoretti的回答使用X11会话的ssh转发(或直接TCP连接)

如果您的笔记本电脑上有Windows并且不想运行Windows,则选项1或2很有用X11服务器就可以了。然后您可以使用 Windows 本机 VNC 客户端。

您还可以使用 RDP 代替 VNC(X11 端为 X11rdp 或 xrdp,Windows 端为 RDP 客户端)。这应该会提供更快的刷新率,但据说在 X11 端设置起来比较困难(我个人没有这样做过)。 OTOH Windows 有一个内置的 RDP 客户端,因此您甚至无需在 Windows 端安装任何内容。

如果您的笔记本电脑上有 X11,则使用选项 3 会容易得多。

You can either

  1. Run Xvnc and connect to it using a VNC client
  2. Run Xvfb together with x11vnc and connect to it using a VNC client (this is different from the above but the end result for you is the same; useful only if you already run Xvfb for some other reason)
  3. Use ssh forwarding of X11 sessions (or a direct TCP connection) as per favoretti's answer

Options 1 or 2 are useful if you have Windows on your laptop and don't want to run an X11 server on it. You can use a Windows native VNC client then.

You can also RDP instead of VNC (X11rdp or xrdp on the X11 side and RDP client on the Windows side). This should give faster refresh rates but it's supposedly harder to set-up on the X11 side (I haven't done it personally). OTOH Windows has a built-in RDP client so you don't even have to install anything on the Windows side.

If you have X11 on your laptop, it's much easier to use option 3.

梦里的微风 2024-12-25 14:09:18

我没有足够的“代表”来评论其他用户的答案,所以我的帖子是为了增强“favoretti”的好答案。

如果您运行的是 Windows PC,请安装 cygwin unix 子系统并安装 x-windows 和 ssh。如果使用 OSX 启动 X11 或 Mavericks 及以上版本,请安装 xQuartz。

然后,如上所述,您可以 ssh 进入目标(无头)远程服务器并指定 -X 标志以允许 X 流量通过线路返回

 ssh -l <user> -X -v <host>

您可能需要也可能不需要调用命令

xhost + 

来允许 X 流量流回您的计算机。

I don't have enough "Rep" to comment on another user's answer, so my post is for the purpose of augmenting "favoretti"'s good answer.

If you a running a Windows PC, install the cygwin unix subsystem and install x-windows and ssh. If using OSX startup X11 or for Mavericks onward, install xQuartz.

Then as mentioned you can ssh into the target (headless) remote server and specify the -X flag to allow X traffic to come back over the wire

 ssh -l <user> -X -v <host>

You may or may not have to invoke the command

xhost + 

to permit X traffic to flow back to your machine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文