2

First I asked this question in stackoverflow, but it looks like a server issue more than coding problem. I am developing a project with Java EE and I have access to the server computer under a university LAN. Just to give details I also add my codes below.

I am trying to connect to the server through WebSockets only on a single page.

My client websocket:

var socket = new WebSocket("wss://serverName:8181/projectName/actions");

Java Server Endpoint:

/actions

The URL where websocket is used has this structure:

https://serverName/projectName/pageName.xhtml

My context root is same as the project name. Security constraints in web.xml file:

<security-constraint>  
    <web-resource-collection>  
        <web-resource-name>SecureResource</web-resource-name>  
        <url-pattern>/projectName/*</url-pattern>  
        <http-method>GET</http-method>
        <http-method>POST</http-method> 
    </web-resource-collection>  
    <user-data-constraint>  
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>  
    </user-data-constraint>  
</security-constraint>

I use Glassfish Application Server 4.1. The server has two http listeners. About listeners:

Http-Listener-1: listens port 8080, security is not enabled, websocket support is not enabled

Http-Listener-2: listens port 8181, security is enabled, websocket is enabled

SSL3 and TLS is Enabled in both of them. I am giving the server details because I am really a beginner about the server issues, so I dont know if these details are important. I also run the following commands while trying to find a fix. But these commands might not be related:

asadmin set server.network-config.protocols.protocol.http-listener-1.http.scheme-mapping=X-Forwarded-Proto
asadmin set server.network-config.protocols.protocol.http-listener-2.http.scheme-mapping=X-Forwarded-Proto

My all connections works on HTTPS without a problem. However, in the page where I use the websocket I get this error:

WebSocket connection to 'wss://serverName:8181/projectName/actions' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

I have tried a lot of different approach. I also tried the websocket URI without the port number. Everything had worked fine before we had a digital certificate on the server computer. I just used 'ws' instead of 'wss' back then and I didnt have the security constraints in the web.xml file. However, I am unable to provide websocket connection under HTTPS after a lot of reading and tries.

tonder
  • 21
  • 1
  • 1
  • 2
  • This means that no TCP connection could be established to the server. Make sure that the server is actually running at this port and is reachable from outside, i.e. running on the external IP address of the machine and not only on localhost and that no firewall on the server or somewhere in the path from the client to the server is blocking the access. The information you provide in your question are not usable to verify this. – Steffen Ullrich Apr 28 '18 at 04:24
  • I checked if the server ports are reachable from outside and I saw that port 8080 and 8181 are closed. However, I am confused with this because I have two glassfish listeners listening from these ports, and I can connect to the project with https. How am I able to connect to the app if the listener ports are closed? I opened port 8181 later and now I am getting net::ERR_CERT_AUTHORITY_INVALID error. I guess there is something wrong with the certificate? Any ideas? Thanks! – tonder Apr 29 '18 at 01:01
  • I have no idea what you are really doing. You are right that the error indicates that something is wrong with the certificate. But again, you don't provide any kind information which might help to debug the issue further. – Steffen Ullrich Apr 29 '18 at 04:03
  • I have a Java EE project that is deployed on a glassfish application server placed on a server computer. All web pages of the project are reachable through https and has no problem. Only a single page uses websockets(which doesnt work). The glassfish application server has two http listeners which listen from port 8080 and 8181. However, when I checked the ports on canyouseeme.org website, I saw that they are unreachable. Thats why I opened port 8181 on the server computer. Now, I get this new error on the websocket page. I really dont know what kind of info I can provide. any suggestion? – tonder Apr 29 '18 at 04:50
  • Given that you are dealing with a certificate validation problem you should check your certificate setup - that's all I can extract from the information you've provided. – Steffen Ullrich Apr 29 '18 at 06:01

0 Answers0