question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Only the first request works

See original GitHub issue

Hi! I’m trying to use HttpTwo with APNS (development server). Any first request (POST, Connect, Ping) is processed successfully, but, after that, any other request except Disconnect fails with error of broken connection from the remote party.

var store = new X509Store("MY", StoreLocation.CurrentUser);
            Http2Client request2 = null;
            try
            {
                store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
                var myCert =
                    store.Certificates.Find(X509FindType.FindBySubjectName, "Apple Development IOS Push Services", false)
                        .OfType<X509Certificate2>()
                        .FirstOrDefault();
                //var uri = new Uri("https://api.development.push.apple.com");
                var path =
                    new Uri(
                        "https://api.development.push.apple.com/3/device/somedeviceId");
                request2 = new Http2Client(path, myCert != null ? new X509Certificate2Collection(myCert) : null);                
                store.Close();
                var stream1 = new MemoryStream();
                var notif = new Notification {Aps = new Aps {Alert = "Hello", Sound = "default"}};
                var ser = new DataContractJsonSerializer(typeof (Notification));
                ser.WriteObject(stream1, notif);
                stream1.Position = 0;
                var response = await request2.Send(path, HttpMethod.Post, null, stream1);

Every new request in the same process (even made with new Http2Client instance) is refused by server. What do I do wrong?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Mazerorcommented, Nov 28, 2017

Hello! I spent couple of days, trying to make this lib working. Core problems of this lib:

  1. wrong using of TPL-pattern (lock, symaphore, events, configure.await - all together!). Fristofall, rewrite it to event-based OR tpl model (as you wish).
  2. Re-esteblishing new connection for every push message. It’s wrong, and apple doesn’t like it (as mentioned above). (StreamManager.cs, method Get)
  3. http2 library drops hpack’s dynamic table every frame (Utils.cs, method UnpackHeaders) => can’t parse headers from second and next packets.
  4. no re-connect when GOAWAY o RSTCHANNEL frames are received.

This will be enought for working solution.

Performance also is very pure, but it’s much easyer: change Lists to byte arrays in Frames.

0reactions
meistermcommented, Sep 6, 2016

Are there any solutions yet? I have the same problem firing more than one request to the Server. For example the first Post Command: 11:09:06.326 PM: -> [Frame: SETTINGS, Id=0, Ack=False, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:06.332 PM: <- [Frame: SETTINGS, Id=0, Ack=False, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:06.348 PM: -> [Frame: SETTINGS, Id=0, Ack=True, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:06.355 PM: -> [Frame: HEADERS, Id=1, EndStream=False, EndHeaders=True, Priority=False, Weight=0, Padded=False, PadLength=0, HeaderBlockFragmentLength=144] 11:09:06.357 PM: -> [Frame: DATA, Id=1, EndStream=True, Padded=False, PadLength=0, PayloadLength=96] 11:09:06.499 PM: <- [Frame: SETTINGS, Id=0, Ack=True, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:06.519 PM: <- [Frame: HEADERS, Id=1, EndStream=False, EndHeaders=True, Priority=False, Weight=0, Padded=False, PadLength=0, HeaderBlockFragmentLength=37] 11:09:06.520 PM: <- [Frame: DATA, Id=1, EndStream=True, Padded=False, PadLength=0, PayloadLength=27] 11:09:06.533 PM: -> [Frame: WINDOW_UPDATE, Id=0, WindowSizeIncrement=27] 11:09:06.540 PM: -> [Frame: GOAWAY, Id=0, ErrorCode=0, LastStreamId=0, AdditionalDebugData=]

This is a connection to Apple Push Notification Service. The Server sends me a goaway frame. But why?

The next post request looks like this:

11:09:29.147 PM: <- [Frame: SETTINGS, Id=0, Ack=False, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:29.149 PM: -> [Frame: SETTINGS, Id=0, Ack=True, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:29.150 PM: -> [Frame: SETTINGS, Id=0, Ack=False, HeaderTableSize=, EnablePush=, MaxConcurrentStreams=, InitialWindowSize=, MaxFrameSize=, MaxHeaderListSize=] 11:09:29.150 PM: -> [Frame: HEADERS, Id=1, EndStream=False, EndHeaders=True, Priority=False, Weight=0, Padded=False, PadLength=0, HeaderBlockFragmentLength=144] 11:09:29.150 PM: -> [Frame: DATA, Id=1, EndStream=True, Padded=False, PadLength=0, PayloadLength=96] 11:09:29.311 PM: <- [Frame: GOAWAY, Id=0, ErrorCode=1, LastStreamId=0, AdditionalDebugData=First received frame was not SETTINGS. Hex dump for first 5 bytes: 0000000401]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Only first request works in bouncy - node.js - Stack Overflow
We are using a node.js script based on bouncy to manage a lot of small tools we run. It proxies the traffic to...
Read more >
An overview of HTTP - MDN Web Docs
HTTP is a protocol for fetching resources such as HTML documents. It is the foundation of any data exchange on the Web and...
Read more >
Sending your first request - Postman Learning Center
Sending your first request. Postman enables you to create and send API requests. Send a request to an endpoint, retrieve data from a...
Read more >
How the web works: HTTP and CGI explained
A web server is a just a computer program that listens for requests from browsers ... The first thing the browser has to...
Read more >
HTTP Request Methods – Get vs Put vs Post Explained with ...
You'll also have experience making requests and working with a web API ... only job is to listen continuously for a request to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found