{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveSocket/reactivesocket-java/issues/13","labels_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket-java/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket-java/issues/13/comments","events_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket-java/issues/13/events","html_url":"https://github.com/ReactiveSocket/reactivesocket-java/issues/13","id":99373358,"number":13,"title":"Move request start/accept to DuplexConnection?","user":{"login":"NiteshKant","id":820005,"avatar_url":"https://avatars.githubusercontent.com/u/820005?v=3","gravatar_id":"","url":"https://api.github.com/users/NiteshKant","html_url":"https://github.com/NiteshKant","followers_url":"https://api.github.com/users/NiteshKant/followers","following_url":"https://api.github.com/users/NiteshKant/following{/other_user}","gists_url":"https://api.github.com/users/NiteshKant/gists{/gist_id}","starred_url":"https://api.github.com/users/NiteshKant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiteshKant/subscriptions","organizations_url":"https://api.github.com/users/NiteshKant/orgs","repos_url":"https://api.github.com/users/NiteshKant/repos","events_url":"https://api.github.com/users/NiteshKant/events{/privacy}","received_events_url":"https://api.github.com/users/NiteshKant/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-06T07:14:07Z","updated_at":"2015-09-23T17:22:22Z","closed_at":null,"body":"Today the interaction with the library in a client/server is as follows:\r\n\r\n```java\r\nDuplexConnection c = createConnection(); // Create from some factory\r\nReactiveSocketClientProtocol p = ReactiveSocketClientProtocol.create(c);\r\np.requestResponse(\"Hello).subscribe();\r\n```\r\n\r\nI see two issues with this approach:\r\n\r\n- (Just a matter of taste) It looks to me that the request initiation belongs to the connection and the protocol abstraction seems unnecessary. So, it would look something like:\r\n\r\n```java\r\nDuplexConnection c = createConnection(); // Create from some factory\r\nc.requestResponse(\"Hello).subscribe();\r\n```\r\n\r\n- The current model does not handle broken connections and re-connect. The reason being that the protocol class does not have the knowledge to re-create a connection. So, in order to solve this issue, we have to go either the way of providing the protocol class with a `Single<DuplexConnection>` or if we move these methods to the connection itself, we just `flatmap` the `Single` and do our stuff. The re-connect would just be a retry in either cases.\r\n\r\nI have recently added a construct in RxNetty to cache a connection till it closes, which would be useful in this case as we would have multiple subscriptions to the `Single<DuplexConnection>` which would need to get the same `DuplexConnection` till it is valid. The relevant class is [here](https://github.com/ReactiveX/RxNetty/blob/0.5.x/rxnetty/src/main/java/io/reactivex/netty/protocol/http/ws/client/OperatorCacheSingleWebsocketConnection.java). "},"comment":{"url":"https://api.github.com/repos/ReactiveSocket/reactivesocket-java/issues/comments/142670536","html_url":"https://github.com/ReactiveSocket/reactivesocket-java/issues/13#issuecomment-142670536","issue_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket-java/issues/13","id":142670536,"user":{"login":"benjchristensen","id":813492,"avatar_url":"https://avatars.githubusercontent.com/u/813492?v=3","gravatar_id":"","url":"https://api.github.com/users/benjchristensen","html_url":"https://github.com/benjchristensen","followers_url":"https://api.github.com/users/benjchristensen/followers","following_url":"https://api.github.com/users/benjchristensen/following{/other_user}","gists_url":"https://api.github.com/users/benjchristensen/gists{/gist_id}","starred_url":"https://api.github.com/users/benjchristensen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjchristensen/subscriptions","organizations_url":"https://api.github.com/users/benjchristensen/orgs","repos_url":"https://api.github.com/users/benjchristensen/repos","events_url":"https://api.github.com/users/benjchristensen/events{/privacy}","received_events_url":"https://api.github.com/users/benjchristensen/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T17:22:22Z","updated_at":"2015-09-23T17:22:22Z","body":"> Do we want to continue previous state when re-connecting. \r\n\r\nWe have decided no."}}