{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/963","labels_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/963/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/963/comments","events_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/963/events","html_url":"https://github.com/couchbase/couchbase-lite-ios/issues/963","id":113698669,"number":963,"title":"Couchbase lite eventually sends invalid heartbeat value for longpoll feed","user":{"login":"alex7egli","id":13315978,"avatar_url":"https://avatars.githubusercontent.com/u/13315978?v=3","gravatar_id":"","url":"https://api.github.com/users/alex7egli","html_url":"https://github.com/alex7egli","followers_url":"https://api.github.com/users/alex7egli/followers","following_url":"https://api.github.com/users/alex7egli/following{/other_user}","gists_url":"https://api.github.com/users/alex7egli/gists{/gist_id}","starred_url":"https://api.github.com/users/alex7egli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex7egli/subscriptions","organizations_url":"https://api.github.com/users/alex7egli/orgs","repos_url":"https://api.github.com/users/alex7egli/repos","events_url":"https://api.github.com/users/alex7egli/events{/privacy}","received_events_url":"https://api.github.com/users/alex7egli/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/labels/f:%20Replication","name":"f: Replication","color":"f8e100"},{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/labels/in%20progress","name":"in progress","color":"ededed"},{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/labels/size-small","name":"size-small","color":"c7def8"}],"state":"open","locked":false,"assignee":{"login":"snej","id":43241,"avatar_url":"https://avatars.githubusercontent.com/u/43241?v=3","gravatar_id":"","url":"https://api.github.com/users/snej","html_url":"https://github.com/snej","followers_url":"https://api.github.com/users/snej/followers","following_url":"https://api.github.com/users/snej/following{/other_user}","gists_url":"https://api.github.com/users/snej/gists{/gist_id}","starred_url":"https://api.github.com/users/snej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snej/subscriptions","organizations_url":"https://api.github.com/users/snej/orgs","repos_url":"https://api.github.com/users/snej/repos","events_url":"https://api.github.com/users/snej/events{/privacy}","received_events_url":"https://api.github.com/users/snej/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/milestones/13","html_url":"https://github.com/couchbase/couchbase-lite-ios/milestones/1.2","labels_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/milestones/13/labels","id":873603,"number":13,"title":"1.2","description":"Feature release, incorporating ForestDB storage engine","creator":{"login":"snej","id":43241,"avatar_url":"https://avatars.githubusercontent.com/u/43241?v=3","gravatar_id":"","url":"https://api.github.com/users/snej","html_url":"https://github.com/snej","followers_url":"https://api.github.com/users/snej/followers","following_url":"https://api.github.com/users/snej/following{/other_user}","gists_url":"https://api.github.com/users/snej/gists{/gist_id}","starred_url":"https://api.github.com/users/snej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snej/subscriptions","organizations_url":"https://api.github.com/users/snej/orgs","repos_url":"https://api.github.com/users/snej/repos","events_url":"https://api.github.com/users/snej/events{/privacy}","received_events_url":"https://api.github.com/users/snej/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":81,"state":"open","created_at":"2014-11-20T01:04:30Z","updated_at":"2015-11-03T18:59:53Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-10-27T21:56:43Z","updated_at":"2015-11-03T19:05:39Z","closed_at":null,"body":"We are using non-websocket push and pull replicators (set customProperties.webSocket to 0), couchbase lite 1.1.1 and sync gateway 1.1.1. After a few minutes our Pull replication will get a 400 response for one of the POST _changes requests and this kills the replication. It doesn't try to reconnect or anything so after that we don't retrieve any changes from the server. I can see in the sync gateway logs that the problem is invalid json:\r\n21:43:41.016608 2015-10-27T21:43:41.016Z HTTP: #2524:     --> 400 Invalid JSON: \"json: cannot unmarshal number 45190.0027692318 into Go value of type uint64\"  (27.1 ms)\r\n\r\nI can see from the packets being sent from the client to the server that the value is from the heartbeat parameter:\r\n{\"heartbeat\":45921.76951467991,\"feed\":\"longpoll\",\"style\":\"all_docs\",\"filter\":\"sync_gateway\\/bychannel\",\"since\":251208,\"channels\":\"long list of channels\"}\r\n\r\nAt some point during the replication this pops up in the app logs:\r\n2015-10-27 17:39:29.986 PUSH[422:44022] WARNING: CBLSocketChangeTracker[0x1baafe80 dbws]: Longpoll connection closed (by proxy?) after 61.2 sec \r\n\r\nIn the couchbase lite code that warning comes before code that sets heartbeat to elapsed * 0.75 (in this case elapsed rounded to 1 decimal place is 61.2) Source > Replicator > ChangeTracker > CBLSocketChangeTracker.m line 250 in release/1.1.1. Basically if elapsed is precise to a sufficient number of decimal places it breaks the replication. Please round elapsed up before multiplying, or round the multiplication result to a value that sync gateway can unmarshal."},"comment":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/comments/153455985","html_url":"https://github.com/couchbase/couchbase-lite-ios/issues/963#issuecomment-153455985","issue_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/963","id":153455985,"user":{"login":"snej","id":43241,"avatar_url":"https://avatars.githubusercontent.com/u/43241?v=3","gravatar_id":"","url":"https://api.github.com/users/snej","html_url":"https://github.com/snej","followers_url":"https://api.github.com/users/snej/followers","following_url":"https://api.github.com/users/snej/following{/other_user}","gists_url":"https://api.github.com/users/snej/gists{/gist_id}","starred_url":"https://api.github.com/users/snej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snej/subscriptions","organizations_url":"https://api.github.com/users/snej/orgs","repos_url":"https://api.github.com/users/snej/repos","events_url":"https://api.github.com/users/snej/events{/privacy}","received_events_url":"https://api.github.com/users/snej/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T19:05:39Z","updated_at":"2015-11-03T19:05:39Z","body":"Fixed on the release/1.2 branch. (Trivial 1-line patch if you want to cherry-pick it, Alex)"}}