Open optimojordan opened 1 year ago
For me upgrading to a newer httpcomponents
version helped, since it is more robust against improper server responses, e.g. using Maven:
<properties>
<httpcomponents.version>5.2.1</httpcomponents.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpcomponents.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
<version>${httpcomponents.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5-h2</artifactId>
<version>${httpcomponents.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5-reactive</artifactId>
<version>${httpcomponents.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Describe the bug When attempting to send a simple notification using com.windowsazure:Notification-Hubs-java-sdk:1.0.3 using a brand new, empty project that does nothing else, it appears that if Spring is also a dependency in the build file, this exception occurs when we attempt to send the notification.
Exception or Stack Trace java.lang.RuntimeException: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]> at com.windowsazure.messaging.SyncCallback.failed(SyncCallback.java:53) at com.windowsazure.messaging.NotificationHubsService$1.failed(NotificationHubsService.java:78) at org.apache.hc.core5.concurrent.BasicFuture.failed(BasicFuture.java:138) at org.apache.hc.core5.concurrent.ComplexFuture.failed(ComplexFuture.java:86) at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$3.failed(InternalAbstractHttpAsyncClient.java:345) at org.apache.hc.client5.http.impl.async.AsyncRedirectExec$1.failed(AsyncRedirectExec.java:246) at org.apache.hc.client5.http.impl.async.AsyncHttpRequestRetryExec$1.failed(AsyncHttpRequestRetryExec.java:167) at org.apache.hc.client5.http.impl.async.AsyncProtocolExec$1.failed(AsyncProtocolExec.java:281) at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.failed(HttpAsyncMainClientExec.java:124) at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.failed(ClientHttp1StreamHandler.java:295) at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.terminate(ClientHttp1StreamDuplexer.java:193) at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.shutdownSession(AbstractHttp1StreamDuplexer.java:164) at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onException(AbstractHttp1StreamDuplexer.java:404) at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:66) at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:41) at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:575) at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$400(SSLIOSession.java:72) at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:172) at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:133) at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51) at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178) at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127) at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85) at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]> at org.apache.hc.core5.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:110) at org.apache.hc.core5.http.message.BasicLineParser.parseStatusLine(BasicLineParser.java:181) at org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:83) at org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:44) at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parseHeadLine(AbstractMessageParser.java:115) at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parse(AbstractMessageParser.java:167) at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parse(AbstractMessageParser.java:51) at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.parseMessageHead(AbstractHttp1StreamDuplexer.java:256) at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:287) at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:64) ... 11 more
To Reproduce 1) Create a simple Spring project with no content 2) Add the following to the build.gradle file:
3) Create a simple unit test to confirm the project can run, e.g.
This test should run and pass.
4) Now create a simple unit test to send a simple notification (see snippet below)
Code Snippet
Expected behavior Expected a notification to be sent to the device whose token corresponds with ARBITRARY_TOKEN
Screenshots If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
Additional context This was also tried with a simple Android app project and simple notifications succeeded, suggesting that classes involved in the Android gradle plugin(s) or dependencies are possibly superseding the classes that are causing the Invalid Protocol Error in the non-android app.
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.