You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2017/12/06 05:13:17 UTC
[GitHub] massakam opened a new pull request #943: Start receiving messages after WebSocket session established
massakam opened a new pull request #943: Start receiving messages after WebSocket session established
URL: https://github.com/apache/incubator-pulsar/pull/943
### Motivation
In rare cases, WebSocket client that start consuming can not receive any messages from WebSocket Proxy even though messages still in the backlog.
As a result of the investigation, I found that NullPointerException occurred at either of the following lines:
* https://github.com/apache/incubator-pulsar/blob/bcc74044288932acc9e83b04001bf1ced17d7780/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/ConsumerHandler.java#L118
* https://github.com/apache/incubator-pulsar/blob/bcc74044288932acc9e83b04001bf1ced17d7780/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/ConsumerHandler.java#L136
It seems that `getSession()` returns null because WebSocket session establishment has not been completed.
### Modifications
Move the first call of `receiveMessage()` from the constructor to `onWebSocketConnect()` in ConsumerHandler.
### Result
ConsumerHandler starts receiving messages after WebSocket session established.
Therefore, we can avoid NullPointerException.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services