{"action":"closed","issue":{"url":"https://api.github.com/repos/rejectedsoftware/vibe.d/issues/1441","repository_url":"https://api.github.com/repos/rejectedsoftware/vibe.d","labels_url":"https://api.github.com/repos/rejectedsoftware/vibe.d/issues/1441/labels{/name}","comments_url":"https://api.github.com/repos/rejectedsoftware/vibe.d/issues/1441/comments","events_url":"https://api.github.com/repos/rejectedsoftware/vibe.d/issues/1441/events","html_url":"https://github.com/rejectedsoftware/vibe.d/issues/1441","id":136083682,"number":1441,"title":"Error after server returns connection close","user":{"login":"skoppe","id":6967044,"avatar_url":"https://avatars.githubusercontent.com/u/6967044?v=3","gravatar_id":"","url":"https://api.github.com/users/skoppe","html_url":"https://github.com/skoppe","followers_url":"https://api.github.com/users/skoppe/followers","following_url":"https://api.github.com/users/skoppe/following{/other_user}","gists_url":"https://api.github.com/users/skoppe/gists{/gist_id}","starred_url":"https://api.github.com/users/skoppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skoppe/subscriptions","organizations_url":"https://api.github.com/users/skoppe/orgs","repos_url":"https://api.github.com/users/skoppe/repos","events_url":"https://api.github.com/users/skoppe/events{/privacy}","received_events_url":"https://api.github.com/users/skoppe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rejectedsoftware/vibe.d/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/rejectedsoftware/vibe.d/labels/regression","name":"regression","color":"600080"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-02-24T14:53:06Z","updated_at":"2016-02-27T08:35:01Z","closed_at":"2016-02-27T08:35:01Z","body":"Using vibe.d 0.7.29 and dmd 2.070\r\n\r\nI am writing an adapter to move data from CouchDB into ElasticSearch. There are aroung 600 small databases that I need to move over. CouchDB is behind an nginx proxy with SSL termination.\r\n\r\nI have determined that CouchDB sends a `connection:close` response header on api call no. 99 (due to some setting) Then things go haywire.\r\n\r\nWith libevent the app blocks at `res.readJson()` in the `requestHttp`. With libasync it fails on the next call to requestHttp with exception saying `Socket operation on nonsocket.`\r\n\r\nWhat I think happens is that CouchDB closes the connection, and vibe.d or nginx isn't handling SSL finalizing properly. \r\n\r\nThis is my course of action:\r\n\r\n1) ~~will try https://ma.ttias.be/enable-keepalive-connections-in-nginx-upstream-proxy-configurations/ as per https://github.com/rejectedsoftware/vibe.d/issues/1400~~ (*didn't do much, although one time I got 299 calls before freezing*)\r\n2) ~~I will look in the nginx and couchdb logs.~~ (*didn't say much*)\r\n3) I will get rid of the nginx proxy in the middle and try again. (*confirmed this worked*)\r\n4) Find a way how to get my adapter to close the connection before reaching 100, and force opening a new one.\r\n\r\nHere is a log for a correct call (libevent):\r\n\r\n```\r\n[02BD0000:02BD3100 trc] returning HTTPClient connection 0 of 1\r\n[02BD0000:02BD3100 trc] --------------------\r\n[02BD0000:02BD3100 trc] HTTP client request:\r\n[02BD0000:02BD3100 trc] --------------------\r\n[02BD0000:02BD3100 trc] GET /a26c3188d-59f4-4aea-80b0-43c523be38da HTTP/1.1\r\n[02BD0000:02BD3100 trc] User-Agent: vibe.d/0.7.27 (HTTPClient, +http://vibed.org/)\r\n[02BD0000:02BD3100 trc] Connection: keep-alive\r\n[02BD0000:02BD3100 trc] Accept-Encoding: gzip, deflate\r\n[02BD0000:02BD3100 trc] Host: app-data.21brains.com\r\n[02BD0000:02BD3100 trc] Accept: application/json\r\n[02BD0000:02BD3100 trc] evbuffer_add (fd 556): 285 B\r\n[02BD0000:02BD3100 trc] Content-Type: application/json\r\n[02BD0000:02BD3100 trc] Authorization: Basic xxxx\r\n[02BD0000:02BD3100 trc] --------------------\r\n[02BD0000:02BD3100 trc] evbuffer_add (fd 556): 94 B\r\n[02BD0000:02BD3100 trc] HTTP client waiting for response\r\n[02BD0000:00000000 trc] socket 556 write event (false)!\r\n[02BD0000:00000000 trc] socket 556 read event!\r\n[02BD0000:02BD3100 trc] HTTP client reading status line\r\n[02BD0000:02BD3100 trc] stln: HTTP/1.1 200 OK\r\n[02BD0000:02BD3100 trc] ---------------------\r\n[02BD0000:02BD3100 trc] HTTP client response:\r\n[02BD0000:02BD3100 trc] ---------------------\r\n[02BD0000:02BD3100 trc] HTTP/1.1 200 OK\r\n[02BD0000:02BD3100 trc] Server: nginx/1.9.5\r\n[02BD0000:02BD3100 trc] Date: Wed, 24 Feb 2016 09:58:46 GMT\r\n[02BD0000:02BD3100 trc] Content-Type: application/json\r\n[02BD0000:02BD3100 trc] Content-Length: 266\r\n[02BD0000:02BD3100 trc] Connection: keep-alive\r\n[02BD0000:02BD3100 trc] Cache-Control: must-revalidate\r\n[02BD0000:02BD3100 trc] Strict-Transport-Security: max-age=31536000\r\n[02BD0000:02BD3100 trc] ---------------------\r\n[02BD0000:00000000 trc] socket 556 read event!\r\n```\r\n\r\nHere the failing one (libevent):\r\n\r\n```\r\n[02BD0000:02BD3100 trc] returning HTTPClient connection 0 of 1\r\n[02BD0000:02BD3100 trc] --------------------\r\n[02BD0000:02BD3100 trc] HTTP client request:\r\n[02BD0000:02BD3100 trc] --------------------\r\n[02BD0000:02BD3100 trc] GET /a26e0aa8c-ca37-4fd0-add7-432b991da964 HTTP/1.1\r\n[02BD0000:02BD3100 trc] User-Agent: vibe.d/0.7.27 (HTTPClient, +http://vibed.org/)\r\n[02BD0000:02BD3100 trc] Connection: keep-alive\r\n[02BD0000:02BD3100 trc] Accept-Encoding: gzip, deflate\r\n[02BD0000:02BD3100 trc] Host: app-data.21brains.com\r\n[02BD0000:02BD3100 trc] Accept: application/json\r\n[02BD0000:02BD3100 trc] evbuffer_add (fd 556): 285 B\r\n[02BD0000:02BD3100 trc] Content-Type: application/json\r\n[02BD0000:02BD3100 trc] Authorization: Basic xxxx\r\n[02BD0000:02BD3100 trc] --------------------\r\n[02BD0000:02BD3100 trc] evbuffer_add (fd 556): 94 B\r\n[02BD0000:02BD3100 trc] HTTP client waiting for response\r\n[02BD0000:00000000 trc] socket 556 write event (false)!\r\n[02BD0000:00000000 trc] socket 556 read event!\r\n[02BD0000:02BD3100 trc] HTTP client reading status line\r\n[02BD0000:02BD3100 trc] stln: HTTP/1.1 200 OK\r\n[02BD0000:02BD3100 trc] ---------------------\r\n[02BD0000:02BD3100 trc] HTTP client response:\r\n[02BD0000:02BD3100 trc] ---------------------\r\n[02BD0000:02BD3100 trc] HTTP/1.1 200 OK\r\n[02BD0000:02BD3100 trc] Server: nginx/1.9.5\r\n[02BD0000:02BD3100 trc] Date: Wed, 24 Feb 2016 09:58:47 GMT\r\n[02BD0000:02BD3100 trc] Content-Type: application/json\r\n[02BD0000:02BD3100 trc] Content-Length: 260\r\n[02BD0000:02BD3100 trc] Connection: close\r\n[02BD0000:02BD3100 trc] Cache-Control: must-revalidate\r\n[02BD0000:02BD3100 trc] Strict-Transport-Security: max-age=31536000\r\n[02BD0000:02BD3100 trc] ---------------------\r\n[02BD0000:00000000 trc] socket 556 read event!\r\n[02BD0000:02BD3100 trc] OpenSSLStream finalize\r\n[02BD0000:02BD3100 trc] evbuffer_add (fd 556): 31 B\r\n[02BD0000:02BD3100 dbg] TCP close request true open\r\n[02BD0000:02BD3100 dia] Actively closing TCP connection\r\n[02BD0000:02BD3100 trc] Closing socket 556...\r\n[02BD0000:00000000 dbg] Socket event on fd 556: 17 (DF4044 vs DF4044)\r\n[02BD0000:00000000 dbg] Connection was closed (fd 556).\r\n```\r\n\r\nand the failing libasync one\r\n\r\n```\r\n[02CA0000:02CA3200 trc] returning HTTPClient connection 0 of 1\r\n[02CA0000:02CA3200 trc] Async resolved address xxx.xxx.xxx.xxx:0\r\n[02CA0000:02CA3200 trc] Acquire Writer\r\n[02CA0000:00000000 trc] Handler\r\n[02CA0000:00000000 trc] onClose\r\n[02CA0000:00000000 trc] exception trap\r\n[02CA0000:02CA3200 CRITICAL] Task terminated with uncaught exception: Socket operation on nonsocket.\r\n[02CA0000:02CA3200 dbg] Full error: object.Exception@C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\drivers\\libasync.d(1451): Socket operation on nonsocket.\r\n[02CA0000:02CA3200 dbg] ----------------\r\n0x004FCDF7 in @safe void vibe.core.core.VibeDriverCore.processDeferredExceptions(vibe.core.task.Task) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\core.d(1327)\r\n0x004FC47F in @safe void vibe.core.core.VibeDriverCore.yieldForEvent() at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\core.d(1203)\r\n0x004EA110 in vibe.core.drivers.libasync.LibasyncTCPConnection vibe.core.drivers.libasync.LibasyncDriver.connectTCP(libasync.windows.NetworkAddress) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\drivers\\libasync.d(292)\r\n0x004E626E in vibe.core.net.TCPConnection vibe.core.net.connectTCP(libasync.windows.NetworkAddress)\r\n0x004E080D in vibe.core.net.TCPConnection vibe.core.net.connectTCP(immutable(char)[], ushort) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\net.d(96)\r\n0x004965A9 in bool vibe.http.client.HTTPClient.doRequest(scope void delegate(vibe.http.client.HTTPClientRequest), bool*, bool, std.datetime.SysTime) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\http\\client.d(534)\r\n0x004963C5 in bool vibe.http.client.HTTPClient.doRequestWithRetry(scope void delegate(vibe.http.client.HTTPClientRequest), bool, out bool, out std.datetime.SysTime) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\http\\client.d(472)\r\n0x00495F87 in void vibe.http.client.HTTPClient.request(scope void delegate(scope vibe.http.client.HTTPClientRequest), scope void delegate(scope vibe.http.client.HTTPClientResponse)) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\http\\client.d(406)\r\n0x004A392D in void vibe.http.client.requestHTTP(vibe.inet.url.URL, scope void delegate(scope vibe.http.client.HTTPClientRequest), scope void delegate(scope vibe.http.client.HTTPClientResponse), vibe.http.client.HTTPClientSettings) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\http\\client.d(137)\r\n0x0049AEAD in void vibe.http.client.requestHTTP(immutable(char)[], scope void delegate(scope vibe.http.client.HTTPClientRequest), scope void delegate(scope vibe.http.client.HTTPClientResponse), vibe.http.client.HTTPClientSettings) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\http\\client.d(107)\r\n0x004318F3 in couch.DBInfo couch.getDbInfo!(settings.Settings).getDbInfo(settings.Settings, immutable(char)[]) at c:\\Users\\Bas\\dev\\21brains\\sourcing-tool-log-adapter-service\\source\\couch.d(145)\r\n0x00406CE1 in void app.main().__lambda1() at c:\\Users\\Bas\\dev\\21brains\\sourcing-tool-log-adapter-service\\source\\app.d(88)\r\n0x00420BBA in void vibe.core.core.makeTaskFuncInfo!(void delegate()).makeTaskFuncInfo(ref void delegate()).callDelegate(vibe.core.core.TaskFuncInfo*) at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\core.d(499)\r\n0x004D98B2 in void vibe.core.core.CoreTask.run() at C:\\Users\\Bas\\AppData\\Roaming\\dub\\packages\\vibe-d-0.7.27\\source\\vibe\\core\\core.d(1085)\r\n0x005AC99D in void core.thread.Fiber.run()\r\n[02CA0000:02CA3200 trc] Emitting signal\r\n[02CA0000:02CA3200 trc] Looping signals. found: 0\r\n```"}}