• 14
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I have an android application and I am trying to make an http/2 call with okHttp version 3.13.1, in my case for one request I will be receiving two responses sequentially from the server, but with the okHttp client I am getting only one response and if I try to send the request using curl command I am receiving two responses sequentially from the server.

Is there a way to handle multiple responses for a single http/2 request in android?

I tried various ways, but no luck:( Would be more than happy, if anyone could provide your inputs.

Thanks for your help and time in advance!!!

I am basically sending a get request from my android application using okHttp client to a server which supports http/2, so expecting to receive 2 different response for that single request in a timely manner.i.e the second response will be sent from the server after 5 seconds gap of receiving the first response.

Below is my response :

First response event:initialize

{"session_id":"df313001-6461-431c-bcc1-7cb931bda4f5","deviceId":"YL0012345678"}

Second response event:voice_response data:{"intents":[{"version":0,"intent":"telstra_intent_voice","params":{"voiceResponse":{"displayText":"Launching now","vuiFileName":"E03.01.P2.V01.E.wav"},"action":{"ecp":"/launch-install/71361"}}}],"deviceId":"YL0012345678","channelId":"269671"}

But, in my case once I receive the first response the client is no longer listing to the server. When I receive the first response, in my log I see : com.example.okhttp3 D/OkHttp: <-- END HTTP (166-byte body), so not receiving the second response.

Appreciate your help!

I found a workaround. You can send the response as multipart data. Then encapsulate all your responses into the multipart data seperated by 'boundary'. The multipart data will not end until you send the 'end mark'(0). Then the client side could decode all the responses one by one simultaneously when the server sending the multipart data. The multipart data will looks like this:

--boundary
response_1

--boundary
response_2

...
--boundary--

0

there is also a demo here.

  • 1
Reply Report