Hello I am creating guacamole driven application and getting error java.net.ConnectException: Connection refused: connect. I tried the code given in guacamole web application documentation getting java.net.ConnectException: Connection refused: connect error
servlet code
@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);
}
}
web page
<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>
What else configuration need to be done. Thanks in advance
There is a configuration issue in the Java code. The GuacamoleConfiguration
object should have the configuration of the target machine (windows) you are connecting to.
In your case, you are using the RDP
protocol, so the hostname
should have the address of the Windows machine you want to connect to. The username
and password
for the target windows machine are mandatory when RDP
protocol is used. If you are using a domain user, you should also specify the domain
parameter.
I believe the basis of your code is from the Guacamole example. This example explains how to connect to the VNC
server, which does not require a username. In general, the basic configuration for connecting to windows should look like this:
// 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");