收到错误连接被拒绝:连接鳄梨酱驱动的应用程序
GETTING ERROR Connection refused: connect for guacamole driven application
您好,我正在创建鳄梨酱驱动的应用程序并收到错误 java.net.ConnectException:连接被拒绝:连接。我尝试了鳄梨调味酱 Web 应用程序文档中给出的代码 java.net.ConnectException: Connection refused: connect error
servlet 代码
@WebServlet
public class HttpTunnelServletController extends GuacamoleHTTPTunnelServlet {
private static final long serialVersionUID = 1L;
public static SimpleGuacamoleTunnel tunnel = null;
@Override
protected GuacamoleTunnel doConnect(HttpServletRequest request)
throws GuacamoleException {
// Create our configuration
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("rdp");
config.setParameter("hostname", "104.197.255.190:8080/guacamole");
config.setParameter("port", "3389");
config.setParameter("password", "guacamole");
// Connect to guacd - everything is hard-coded here.
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket("localhost", 4822),
config
);
// Return a new tunnel which uses the connected socket
return new SimpleGuacamoleTunnel(socket);
}
}
网页
<div class="col-sm-9 col-md-6 col-lg-8 col-xl-10">
<span class="border">
<form action="/GuacamoleHTTPTunnelServletController" >
<!-- Guacamole -->
<script type="text/javascript"
src="guacamole-common-js/all.min.js"></script>
<!-- Display -->
<div id="display"></div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.HTTPTunnel("/tunnel")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
/* ]]> */ </script> <!-- Guacamole -->
<script type="text/javascript"
src="guacamole-common-js/all.min.js"></script>
<!-- Display -->
<div id="display"><a href="tunnel">URL</a></div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.HTTPTunnel("tunnel")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
/* ]]> */ </script>
</form>
</span>
</div>
</div>
</div>
</div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onmousedown =
mouse.onmouseup =
mouse.onmousemove = function(mouseState) {
guac.sendMouseState(mouseState);
};
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
guac.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
guac.sendKeyEvent(0, keysym);
};
/* ]]> */ </script>
还需要做什么配置。提前致谢
Java 代码中存在配置问题。 GuacamoleConfiguration
对象应该具有您要连接的目标机器 (windows) 的配置。
在你的例子中,你使用的是 RDP
协议,所以 hostname
应该有你想要连接的 Windows 机器的地址。当使用 RDP
协议时,目标 windows 机器的 username
和 password
是强制性的。如果您使用域用户,还应指定 domain
参数。
我相信您的代码的基础来自 Guacamole 示例。此示例说明如何连接到不需要用户名的 VNC
服务器。一般来说,连接到 windows 的基本配置应该是这样的:
// Create our configuration
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("rdp");
config.setParameter("hostname", "104.197.255.190"); // IP or fqdn of the windows machine, no URL
config.setParameter("port", "3389");
config.setParameter("username", "some-windows-user");
config.setParameter("password", "some-windows-user-password");
config.setParameter("domain", "windows-domain-if-exists");
您好,我正在创建鳄梨酱驱动的应用程序并收到错误 java.net.ConnectException:连接被拒绝:连接。我尝试了鳄梨调味酱 Web 应用程序文档中给出的代码 java.net.ConnectException: Connection refused: connect error
servlet 代码
@WebServlet
public class HttpTunnelServletController extends GuacamoleHTTPTunnelServlet {
private static final long serialVersionUID = 1L;
public static SimpleGuacamoleTunnel tunnel = null;
@Override
protected GuacamoleTunnel doConnect(HttpServletRequest request)
throws GuacamoleException {
// Create our configuration
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("rdp");
config.setParameter("hostname", "104.197.255.190:8080/guacamole");
config.setParameter("port", "3389");
config.setParameter("password", "guacamole");
// Connect to guacd - everything is hard-coded here.
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket("localhost", 4822),
config
);
// Return a new tunnel which uses the connected socket
return new SimpleGuacamoleTunnel(socket);
}
}
网页
<div class="col-sm-9 col-md-6 col-lg-8 col-xl-10">
<span class="border">
<form action="/GuacamoleHTTPTunnelServletController" >
<!-- Guacamole -->
<script type="text/javascript"
src="guacamole-common-js/all.min.js"></script>
<!-- Display -->
<div id="display"></div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.HTTPTunnel("/tunnel")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
/* ]]> */ </script> <!-- Guacamole -->
<script type="text/javascript"
src="guacamole-common-js/all.min.js"></script>
<!-- Display -->
<div id="display"><a href="tunnel">URL</a></div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.HTTPTunnel("tunnel")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
/* ]]> */ </script>
</form>
</span>
</div>
</div>
</div>
</div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onmousedown =
mouse.onmouseup =
mouse.onmousemove = function(mouseState) {
guac.sendMouseState(mouseState);
};
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
guac.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
guac.sendKeyEvent(0, keysym);
};
/* ]]> */ </script>
还需要做什么配置。提前致谢
Java 代码中存在配置问题。 GuacamoleConfiguration
对象应该具有您要连接的目标机器 (windows) 的配置。
在你的例子中,你使用的是 RDP
协议,所以 hostname
应该有你想要连接的 Windows 机器的地址。当使用 RDP
协议时,目标 windows 机器的 username
和 password
是强制性的。如果您使用域用户,还应指定 domain
参数。
我相信您的代码的基础来自 Guacamole 示例。此示例说明如何连接到不需要用户名的 VNC
服务器。一般来说,连接到 windows 的基本配置应该是这样的:
// Create our configuration
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("rdp");
config.setParameter("hostname", "104.197.255.190"); // IP or fqdn of the windows machine, no URL
config.setParameter("port", "3389");
config.setParameter("username", "some-windows-user");
config.setParameter("password", "some-windows-user-password");
config.setParameter("domain", "windows-domain-if-exists");