我完成了Push的所有步驟,現在在調用Push時發出以下異常。Worklight Push異常:SocketException:由遠程主機關閉連接
我打電話給IBM的示例推送代碼。我可以在數據庫中看到設備ID,令牌,用戶ID在用戶已經成功訂閱Push時存在。
[4/10/13 18:27:24:647 AST] 00000044 JavaScriptInt I com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation log Push Called -----> userId:aahad notificationText:ThisismyPushMessage
[4/10/13 18:27:24:663 AST] 00000044 JavaScriptInt I com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation log submitNotification >> userId :: aahad, text :: ThisismyPushMessage
[4/10/13 18:27:24:679 AST] 00000045 ApnsConnectio W com.notnoop.apns.internal.ApnsConnectionImpl sendMessage Failed to send message [email protected] trying again
java.net.SocketException: Connection closed by remote host
at com.ibm.jsse2.SSLSocketImpl.k(SSLSocketImpl.java:165)
at com.ibm.jsse2.k.write(k.java:30)
at java.io.OutputStream.write(OutputStream.java:69)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:161)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
at com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
at com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
at com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
at java.util.concurrent.FutureTask.run(FutureTask.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
從WL服務器機器我可以telnet蘋果服務器。
有什麼其他的事情,我必須檢查我的網絡?因爲我的客戶有非常嚴格的證券。
這是我使用的Push適配器功能代碼。
function testNotification(userId ,notificationText){
WL.Logger.debug("Push Called -----> userId:" + userId + " notificationText:"+notificationText);
var userSubscription =
WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText);
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "ClickMe",
alert: notificationText,
payload: {
foo : 'bar'
}
});
return { result: "Notification sent to user :: " + userId };
}
我已經縮小了這個問題。
我在我的本地計算機上推送演示(Windows 7聯想筆記本電腦)WL消費者工作室使用碼頭,它工作正常。我收到通知。
我知道我在做一個錯誤,那就是我正在使用開發APNS證書和分發配置文件....這意味着WL服務器會向錯誤的Apple服務器發送請求。
我在筆記本電腦上面試過以上的東西來測試推送演示,另外我還停下了我的防火牆&諾頓殺毒軟件在我的個人筆記本電腦上,用這種方式Push工作正常。
現在,在客戶端,我重新生成了另一個APNS證書,即生產APNS並使用我試圖實現的分佈配置文件。這次我收到了不同的例外。
[4/11/13 12:36:32:566 AST] 00000046 JavaScriptInt I com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation log Push Called -----> userId:aahad notificationText:This is my First Push Message
[4/11/13 12:36:32:566 AST] 00000046 JavaScriptInt I com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation log submitNotification >> userId :: aahad, text :: This is my First Push Message
[4/11/13 12:36:32:676 AST] 0000003b webcontainer E com.ibm.ws.webcontainer.internal.WebContainer handleRequest SRVE0255E: A WebGroup/Virtual Host to handle /favicon.ico has not been defined.
[4/11/13 12:36:58:066 AST] 00000045 ApnsConnectio E com.notnoop.apns.internal.ApnsConnectionImpl socket Couldn't connect to APNS server
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:381)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:243)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:230)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:377)
at java.net.Socket.connect(Socket.java:539)
at com.ibm.jsse2.SSLSocketImpl.connect(SSLSocketImpl.java:284)
at com.ibm.jsse2.SSLSocketImpl.<init>(SSLSocketImpl.java:712)
at com.ibm.jsse2.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:15)
at com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:133)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
at com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
at com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
at com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
at java.util.concurrent.FutureTask.run(FutureTask.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
at java.lang.Thread.run(Thread.java:772)
[4/11/13 12:36:58:066 AST] 00000045 ApnsConnectio W com.notnoop.apns.internal.ApnsConnectionImpl sendMessage Failed to send message [email protected]c1a1... trying again
com.notnoop.exceptions.NetworkIOException: java.net.ConnectException: Connection timed out: connect
at com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:146)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:160)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:52)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
at com.worklight.integration.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:84)
at com.worklight.integration.notification.apns.APNSMediator.sendNotification(APNSMediator.java:85)
at com.worklight.integration.notification.Mediator$4.run(Mediator.java:174)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
at java.util.concurrent.FutureTask.run(FutureTask.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
at java.lang.Thread.run(Thread.java:772)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:381)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:243)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:230)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:377)
at java.net.Socket.connect(Socket.java:539)
at com.ibm.jsse2.SSLSocketImpl.connect(SSLSocketImpl.java:284)
at com.ibm.jsse2.SSLSocketImpl.<init>(SSLSocketImpl.java:712)
at com.ibm.jsse2.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:15)
at com.notnoop.apns.internal.ApnsConnectionImpl.socket(ApnsConnectionImpl.java:133)
... 13 more
現在,我們需要了解兩件事,我們需要幫助。
(1)通過查看日誌,它是否仍然意味着客戶端某處存在網絡阻塞?
(2)我看到Keychain中的一個區別,它顯示了兩個開發APNS &生產APNS證書。兩者都使用相同的私鑰。開發APS證書顯示應用程序ID「us.com.abc.myApp」爲後期修復程序.....雖然生產APS證書沒有顯示它。 ........ 這樣好嗎?或者它會導致一些問題?.......我嘗試重新生成生產APNS證書三次,但每次顯示相同的數字,而不是APP修復後的APP ID。
感謝
我已閱讀它。我正確地做了所有步驟,這就是爲什麼在我的本地筆記本電腦Push工作正常只有在客戶端面臨的問題是非常安全的網絡。第二個問題,上面的共享鏈接也顯示了對我來說很好的開發推送示例。但是我沒有在keyChain的生產APNS證書中看到App ID。例如,如果開發APNS證書:在KeyChain中顯示像這樣** AXD2GH44D.com.ba.myApp **然後生產顯示** AXD2GH44D.AXD2GH44D ** ....我想這兩個爲什麼有區別? – AAhad 2013-04-11 12:20:24
這是一個網絡級別的問題,我的網絡團隊在外部防火牆上打開了端口,並且工作得很完美。 – AAhad 2013-05-05 07:47:12