2015-12-15 222 views
0

我一直在這裏以下WebSocket的教程和一切都很順利:http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.htmlWSS失敗Wildfly 9 openshift

而我部署該應用程序使用openshift Wildfly,一切都很好。 ws正在端口8000上工作。

現在我試圖使用wss來保護websocket。下面是我做的:

web.xml中,我說:

<security-constraint> 
    <display-name>Secure WebSocket Endpoint</display-name> 
    <web-resource-collection> 
     <web-resource-name>Secure WebSocket Endpoint</web-resource-name> 
     <url-pattern>/*</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> 

然後在我的客戶,我取代「WS」與「WSS」,並更改了端口從8000到8443所以它看起來像:

wss://fakeappname.rhcloud.com:8443/actions 

部署更新的應用OpenShift後,我發現網頁被重定向到https,這是很好的。但是wss根本不起作用,沒有錯誤消息。

我在互聯網上搜索了2天,並嘗試了很多不同的方法,但都沒有工作。

我也試圖在.openshift/config/standalone.xml添加https-listener

<https-listener name="default-https" socket-binding="https" security-realm="ApplicationRealm"/> 

其中 「ApplicationRealm」 被定義爲:

<security-realm name="ApplicationRealm"> 
       <authentication> 
        <local default-user="$local" allowed-users="*" skip-group-loading="true"/> 
        <properties path="application-users.properties" relative-to="jboss.server.config.dir"/> 
       </authentication> 
       <authorization> 
        <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/> 
       </authorization> 
      </security-realm> 

但它也不能工作。我不知道爲什麼它在http中起作用,但是在安全性被強制執行時它沒有。

請幫忙!任何提示將不勝感激!

回答

2

經過幾天的研究,事實證明,url-pattern應該是/jsf-pages/*,那麼wss的作品。

+0

我在Openshift上遇到了同樣的問題,我創建了jdbc security-realm,更改爲'/ jsf-pages/*',但是我的websocket沒有「授權」頭部工作... REST服務完美運行。你換了別的東西嗎? – PatrykG