{"action":"created","issue":{"url":"https://api.github.com/repos/smeshlink/CoAP.NET/issues/20","labels_url":"https://api.github.com/repos/smeshlink/CoAP.NET/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/smeshlink/CoAP.NET/issues/20/comments","events_url":"https://api.github.com/repos/smeshlink/CoAP.NET/issues/20/events","html_url":"https://github.com/smeshlink/CoAP.NET/issues/20","id":73024105,"number":20,"title":"CoAP.NET-master Client and Server issue","user":{"login":"Shriyanshmit","id":11751143,"avatar_url":"https://avatars.githubusercontent.com/u/11751143?v=3","gravatar_id":"","url":"https://api.github.com/users/Shriyanshmit","html_url":"https://github.com/Shriyanshmit","followers_url":"https://api.github.com/users/Shriyanshmit/followers","following_url":"https://api.github.com/users/Shriyanshmit/following{/other_user}","gists_url":"https://api.github.com/users/Shriyanshmit/gists{/gist_id}","starred_url":"https://api.github.com/users/Shriyanshmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shriyanshmit/subscriptions","organizations_url":"https://api.github.com/users/Shriyanshmit/orgs","repos_url":"https://api.github.com/users/Shriyanshmit/repos","events_url":"https://api.github.com/users/Shriyanshmit/events{/privacy}","received_events_url":"https://api.github.com/users/Shriyanshmit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-04T13:51:32Z","updated_at":"2015-05-05T02:06:27Z","closed_at":null,"body":"HI,\r\nWhen I send the request to server and process the request using below code working fine\r\nprotected override void DoGet(CoapExchange exchange)\r\n{\r\n// the request contains all the info you sent from your client\r\nRequest request = exchange.Request;\r\n// get payload from the request\r\nstring payload = request.PayloadString;\r\n\r\n        // and respond it\r\n        exchange.Respond(\"Hello\" + payload);\r\n    }\r\nBut when I call REST API for processing the request payload data which take some time for processing the request after process the request when i respond(exchange.Respond(\"Hello\");) to client it returns null.\r\n\r\nprotected override void DoGet(CoapExchange exchange)\r\n{\r\n// the request contains all the info you sent from your client\r\nRequest request = exchange.Request;\r\n// get payload from the request\r\nstring payload = request.PayloadString;\r\n\r\n// process the payload data request using RESTAPI which takes some time in process\r\n\r\n        // and respond it\r\n        exchange.Respond(\"Hello\" + payload);\r\n    }\r\nPlease let me know what is the issue?\r\n\r\nThanks\r\nShreyansh Jian"},"comment":{"url":"https://api.github.com/repos/smeshlink/CoAP.NET/issues/comments/98904800","html_url":"https://github.com/smeshlink/CoAP.NET/issues/20#issuecomment-98904800","issue_url":"https://api.github.com/repos/smeshlink/CoAP.NET/issues/20","id":98904800,"user":{"login":"longshine","id":1046071,"avatar_url":"https://avatars.githubusercontent.com/u/1046071?v=3","gravatar_id":"","url":"https://api.github.com/users/longshine","html_url":"https://github.com/longshine","followers_url":"https://api.github.com/users/longshine/followers","following_url":"https://api.github.com/users/longshine/following{/other_user}","gists_url":"https://api.github.com/users/longshine/gists{/gist_id}","starred_url":"https://api.github.com/users/longshine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/longshine/subscriptions","organizations_url":"https://api.github.com/users/longshine/orgs","repos_url":"https://api.github.com/users/longshine/repos","events_url":"https://api.github.com/users/longshine/events{/privacy}","received_events_url":"https://api.github.com/users/longshine/received_events","type":"User","site_admin":false},"created_at":"2015-05-05T02:06:27Z","updated_at":"2015-05-05T02:06:27Z","body":"I think this is a case for **Separate Response**.\r\n\r\nCoAP has a Timeout mechanism for request/response. If a request hasn't been responded in certain period, (i.e. in 2 seconds), it will be timed out and retransmitted or dropped. In either case, the previous <code>exchange</code> you are processing will be invalid.\r\n\r\nPlease refer to \"Separate\" section in CoAP RFC: http://tools.ietf.org/html/rfc7252#section-5.2.2.\r\n\r\nAs in your code, you could write something like this:\r\n\r\n```csharp\r\nprotected override void DoGet(CoapExchange exchange)\r\n{\r\n  // HERE: Accept the request to promise the client this request will be acted.\r\n  exchange.Accept();\r\n\r\n  Request request = exchange.Request;\r\n  string payload = request.PayloadString;\r\n\r\n  // process the payload data request using RESTAPI which takes some time in process\r\n\r\n  // and respond it with actual response.\r\n  exchange.Respond(\"Hello\" + payload);\r\n}\r\n```\r\n\r\nYou can try visiting the [SeparateResource] (/smeshlink/CoAP.NET/blob/master/CoAP.Example/CoAP.Server/Resources/SeparateResource.cs) on '/separate' in Example/CoAP.Server to see the response result.\r\n\r\nBy the way, you don't have to change your client code for this feature."}}