{"action":"created","issue":{"url":"https://api.github.com/repos/lontivero/Open.NAT/issues/22","labels_url":"https://api.github.com/repos/lontivero/Open.NAT/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/lontivero/Open.NAT/issues/22/comments","events_url":"https://api.github.com/repos/lontivero/Open.NAT/issues/22/events","html_url":"https://github.com/lontivero/Open.NAT/issues/22","id":68957321,"number":22,"title":"Library questions","user":{"login":"at1993","id":11742960,"avatar_url":"https://avatars.githubusercontent.com/u/11742960?v=3","gravatar_id":"","url":"https://api.github.com/users/at1993","html_url":"https://github.com/at1993","followers_url":"https://api.github.com/users/at1993/followers","following_url":"https://api.github.com/users/at1993/following{/other_user}","gists_url":"https://api.github.com/users/at1993/gists{/gist_id}","starred_url":"https://api.github.com/users/at1993/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at1993/subscriptions","organizations_url":"https://api.github.com/users/at1993/orgs","repos_url":"https://api.github.com/users/at1993/repos","events_url":"https://api.github.com/users/at1993/events{/privacy}","received_events_url":"https://api.github.com/users/at1993/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lontivero/Open.NAT/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-16T16:12:04Z","updated_at":"2015-04-17T04:48:13Z","closed_at":null,"body":"When I tested out the ConsoleTest program, I ran into problems at\r\ndevice.GetExternalIPAsync() on three different routers. \r\n\r\nOpen.NAT Information: 0 : Found device at: http://10.10.204.1:1780/InternetGatewayDevice.xml\r\nOpen.NAT Information: 0 : 10.10.204.1:1780: Fetching service list\r\nOpen.NAT Information: 0 : Found device at: http://10.10.204.1:1780/InternetGatewayDevice.xml\r\nOpen.NAT Information: 0 : 10.10.204.1:1780: Parsed services list\r\nOpen.NAT Information: 0 : 10.10.204.1:1780: Found service: urn:schemas-upnp-org:service:WANIPConnection:1\r\nOpen.NAT Information: 0 : 10.10.204.1:1780: Found upnp service at: /control?WANIPConnection\r\nOpen.NAT Information: 0 : 10.10.204.1:1780: Handshake Complete\r\nOpen.NAT Information: 0 : Stop Discovery\r\nOpen.NAT Verbose: 0 : SOAPACTION: **GetExternalIPAddress** url:http://10.235.204.1:1780/control%3FWANIPConnection\r\nOpen.NAT Verbose: 0 : <s:Envelope \r\n   xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" \r\n   s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n   <s:Body>\r\n      <u:GetExternalIPAddress xmlns:u=\"urn:schemas-upnp-org:service:WANIPConnection:1\">\r\n      </u:GetExternalIPAddress>\r\n   </s:Body>\r\n</s:Envelope>\r\nOpen.NAT Verbose: 0 : WebException status: ServerProtocolViolation\r\n\r\nNotice that the UriBuilder replaced the question mark character to %3F. This caused the router to return 404 error.\r\n\r\nSolution:\r\n\r\nServiceControlUri = new Uri(string.Format(\"http://{0}:{1}{2}\", locationUri.Host, locationUri.Port, serviceControlUrl));\r\n\r\n\r\nMy second problem is in GetAllMappingsAsync, one of my routers (sagemcom vdsl modem/router) \r\nreturns mapping entry with internalclient empty. My fix is as follow\r\n\r\npublic override async Task<IEnumerable<Mapping>> GetAllMappingsAsync()\r\n{\r\n    var index = 0;\r\n    var mappings = new List<Mapping>();\r\n    while (true)\r\n            {\r\n                try\r\n                {\r\n                    var message = new GetGenericPortMappingEntry(index);\r\n\r\n                    var responseData = await _soapClient\r\n                        .InvokeAsync(\"GetGenericPortMappingEntry\", message.ToXml())\r\n                        .TimeoutAfter(TimeSpan.FromSeconds(4));\r\n\r\n                    var responseMessage = new GetPortMappingEntryResponseMessage(responseData, DeviceInfo.ServiceType, true);\r\n                    if (!string.IsNullOrEmpty(responseMessage.InternalClient))\r\n                    {\r\n                        var mapping = new Mapping(responseMessage.Protocol\r\n                            , IPAddress.Parse(responseMessage.InternalClient)\r\n                            , responseMessage.InternalPort\r\n                            , responseMessage.ExternalPort\r\n                            , responseMessage.LeaseDuration\r\n                            , responseMessage.PortMappingDescription);\r\n                        mappings.Add(mapping);\r\n                    }\r\n                    index++;\r\n                }\r\n                catch (MappingException e)\r\n                {\r\n                    System.Diagnostics.Debug.WriteLine(e.ToString());\r\n                    if ((e.ErrorCode == UpnpConstants.SpecifiedArrayIndexInvalid) ||\r\n                        (e.ErrorCode == UpnpConstants.NoSuchEntryInArray)) break; // there are no more mappings\r\n                    throw;\r\n                }\r\n            }\r\n\r\n            return mappings.ToArray();\r\n        }\r\n\r\nQuestion: Is there a reason to use UriBuilder if it replaces what it considers illegal characters?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lontivero/Open.NAT/issues/comments/93892614","html_url":"https://github.com/lontivero/Open.NAT/issues/22#issuecomment-93892614","issue_url":"https://api.github.com/repos/lontivero/Open.NAT/issues/22","id":93892614,"user":{"login":"lontivero","id":127973,"avatar_url":"https://avatars.githubusercontent.com/u/127973?v=3","gravatar_id":"","url":"https://api.github.com/users/lontivero","html_url":"https://github.com/lontivero","followers_url":"https://api.github.com/users/lontivero/followers","following_url":"https://api.github.com/users/lontivero/following{/other_user}","gists_url":"https://api.github.com/users/lontivero/gists{/gist_id}","starred_url":"https://api.github.com/users/lontivero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lontivero/subscriptions","organizations_url":"https://api.github.com/users/lontivero/orgs","repos_url":"https://api.github.com/users/lontivero/repos","events_url":"https://api.github.com/users/lontivero/events{/privacy}","received_events_url":"https://api.github.com/users/lontivero/received_events","type":"User","site_admin":false},"created_at":"2015-04-17T04:48:13Z","updated_at":"2015-04-17T04:48:13Z","body":"@at1993 , \r\n\r\n+ Question mark encoded problem was fixed.   \r\n+ DD-WRT linux based router returns 402-Invalid Argument. It was verified and the DD-WRT code is water clear (you can see it below). This means your fix is the only solution.\r\n```\r\nmap = upnp_portmap_with_index(context, ARG_UI2(in_NewPortMappingIndex));\r\nif (!map)\r\n     return SOAP_INVALID_ARGS; \r\n```\r\n+ Sagemcom modem/router. I have problems with this one because the spec is clear: NewInternalClient CANNOT be wildcard (ie. empty). What you propose is check if responseMessage.InternalClient is empty and in that case just skip the entry. Evidently, if the entry is invalid your fix is ok but, could you send the soap request and response to me? I need to understand the problem better.\r\n\r\nThank you\r\n"}}