Closed lpetrovic05 closed 8 years ago
If you can provide logs I can take a look.
To get log output, the easiest thing you can do is add slf4j-simple as a dependency in your project and enable trace level logging by adding the following command line parameter when you run your code...
-Dorg.slf4j.simpleLogger.defaultLogLevel=trace
I think the problem may have to do with xml tag namespaces. If yes it'll likely be a easy fix. Logs will confirm. On Jul 7, 2016 8:08 AM, "lpetrovic05" notifications@github.com wrote:
Hi, I have a Cisco uPNP router and I'm currently using Cling library to open ports and it works fine. I tried using portmapper with the example given and I got the following exception:
Exception in thread "main" java.lang.IllegalStateException: No response/invalid response to getting external IP at com.offbynull.portmapper.mappers.upnpigd.PortMapperUpnpIgdPortMapper.mapPort(PortMapperUpnpIgdPortMapper.java:121)
Do you have any idea what the problem is? Any tips on how to debug it?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/offbynull/portmapper/issues/26, or mute the thread https://github.com/notifications/unsubscribe/AGD4IvDk0TAUpFm7EFngKp0aX9BdQ7SBks5qTRZugaJpZM4JHLgd .
I turned the debug on, can you make sense of the following:
`[main] DEBUG com.offbynull.portmapper.mapper.MapperIoUtils - Performing tcp requests [TcpRequest{sourceAddress=/192.168.0.12, destinationSocketAddress=/192.168.0.1:80, request=GetExternalIpAddressUpnpIgdRequest{super=UpnpIgdSoapRequest{super=UpnpIgdHttpRequest{method=POST, location=/WANIPConnection, headers={Host=192.168.0.1:80, Content-Type=text/xml, SOAPAction=urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress, Connection=Close, Cache-Control=no-cache, Pragma=no-cache}, content=<?xml version="1.0"?>
The number increments are the lib retrying the request.
Can you post up the entire log? If github won't let you attach to the ticket you can put it up on paste bin and link it. On Jul 7, 2016 8:35 AM, "lpetrovic05" notifications@github.com wrote:
I turned the debug on, can you make sense of the following:
[main] DEBUG com.offbynull.portmapper.mapper.MapperIoUtils - Performing tcp requests [TcpRequest{sourceAddress=/192.168.0.12, destinationSocketAddress=/192.168.0.1:80, request=GetExternalIpAddressUpnpIgdRequest{super=UpnpIgdSoapRequest{super=UpnpIgdHttpRequest{method=POST, location=/WANIPConnection, headers={Host=192.168.0.1:80, Content-Type=text/xml, SOAPAction=urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress, Connection=Close, Cache-Control=no-cache, Pragma=no-cache}, content=<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> soap:Body <u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"> /u:GetExternalIPAddress /soap:Body /soap:Envelope }}}, response=null, requestToBytesTransformer=com.offbynull.portmapper.mappers.upnpigd.UpnpIgdPortMapper$BasicRequestTransformer@2dee4c69, bytesToResponseTransformer=com.offbynull.portmapper.mappers.upnpigd.PortMapperUpnpIgdPortMapper$1@77da990d, other=null}] with durations [main] DEBUG com.offbynull.portmapper.mapper.MapperIoUtils - Creating socket ID for TcpRequest{sourceAddress=/192.168.0.12, destinationSocketAddress=/192.168.0.1:80, request=GetExternalIpAddressUpnpIgdRequest{super=UpnpIgdSoapRequest{super=UpnpIgdHttpRequest{method=POST, location=/WANIPConnection, headers={Host=192.168.0.1:80, Content-Type=text/xml, SOAPAction=urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress, Connection=Close, Cache-Control=no-cache, Pragma=no-cache}, content=<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> soap:Body <u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"> /u:GetExternalIPAddress /soap:Body /soap:Envelope }}}, response=null, requestToBytesTransformer=com.offbynull.portmapper.mappers.upnpigd.UpnpIgdPortMapper$BasicRequestTransformer@2dee4c69, bytesToResponseTransformer=com.offbynull.portmapper.mappers.upnpigd.PortMapperUpnpIgdPortMapper$1@77da990d, other=null} [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - Processing message: com.offbynull.portmapper.gateways.network.internalmessages.GetNextIdNetworkRequest@307661f4 [main] DEBUG com.offbynull.portmapper.mapper.MapperIoUtils - Socket ID for TcpRequest{sourceAddress=/192.168.0.12, destinationSocketAddress=/ 192.168.0.1:80, request=GetExternalIpAddressUpnpIgdRequest{super=UpnpIgdSoapRequest{super=UpnpIgdHttpRequest{method=POST, location=/WANIPConnection, headers={Host=192.168.0.1:80, Content-Type=text/xml, SOAPAction=urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress, Connection=Close, Cache-Control=no-cache, Pragma=no-cache}, content=<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"> soap:Body <u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"> /u:GetExternalIPAddress /soap:Body /soap:Envelope }}}, response=null, requestToBytesTransformer=com.offbynull.portmapper.mappers.upnpigd.UpnpIgdPortMapper$BasicRequestTransformer@2dee4c69, bytesToResponseTransformer=com.offbynull.portmapper.mappers.upnpigd.PortMapperUpnpIgdPortMapper$1@77da990d, other=null} is 30 [main] DEBUG com.offbynull.portmapper.mapper.MapperIoUtils - Creating TCP socket 30 [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - Processing message: CreateTcpNetworkRequest{responseBus=com.offbynull.portmapper.gateway.BasicBus@2c18f307, sourceAddress=/192.168.0.12, destinationAddress=/192.168.0.1, destinationPort=80} [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 Key updated to 13 [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - Processing message: WriteTcpNetworkRequest{super=IdentifiableNetworkRequest{id=30}data=[80, 79, 83, 84, 32, 47, 87, 65, 78, 73, 80, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72, 111, 115, 116, 58, 32, 49, 57, 50, 46, 49, 54, 56, 46, 48, 46, 49, 58, 56, 48, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 116, 101, 120, 116, 47, 120, 109, 108, 13, 10, 83, 79, 65, 80, 65, 99, 116, 105, 111, 110, 58, 32, 117, 114, 110, 58, 115, 99, 104, 101, 109, 97, 115, 45, 117, 112, 110, 112, 45, 111, 114, 103, 58, 115, 101, 114, 118, 105, 99, 101, 58, 87, 65, 78, 73, 80, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 49, 35, 71, 101, 116, 69, 120, 116, 101, 114, 110, 97, 108, 73, 80, 65, 100, 100, 114, 101, 115, 115, 13, 10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 67, 108, 111, 115, 101, 13, 10, 67, 97, 99, 104, 101, 45, 67, 111, 110, 116, 114, 111, 108, 58, 32, 110, 111, 45, 99, 97, 99, 104, 101, 13, 10, 80, 114, 97, 103, 109, 97, 58, 32, 110, 111, 45, 99, 97, 99, 104, 101, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 51, 49, 48, 13, 10, 13, 10, 60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 63, 62, 13, 10, 60, 115, 111, 97, 112, 58, 69, 110, 118, 101, 108, 111, 112, 101, 32, 120, 109, 108, 110, 115, 58, 115, 111, 97, 112, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 50, 48, 48, 51, 47, 48, 53, 47, 115, 111, 97, 112, 45, 101, 110, 118, 101, 108, 111, 112, 101, 47, 34, 32, 115, 111, 97, 112, 58, 101, 110, 99, 111, 100, 105, 110, 103, 83, 116, 121, 108, 101, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 50, 48, 48, 51, 47, 48, 53, 47, 115, 111, 97, 112, 45, 101, 110, 99, 111, 100, 105, 110, 103, 34, 62, 13, 10, 60, 115, 111, 97, 112, 58, 66, 111, 100, 121, 62, 13, 10, 60, 117, 58, 71, 101, 116, 69, 120, 116, 101, 114, 110, 97, 108, 73, 80, 65, 100, 100, 114, 101, 115, 115, 32, 120, 109, 108, 110, 115, 58, 117, 61, 34, 117, 114, 110, 58, 115, 99, 104, 101, 109, 97, 115, 45, 117, 112, 110, 112, 45, 111, 114, 103, 58, 115, 101, 114, 118, 105, 99, 101, 58, 87, 65, 78, 73, 80, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 49, 34, 62, 13, 10, 60, 47, 117, 58, 71, 101, 116, 69, 120, 116, 101, 114, 110, 97, 108, 73, 80, 65, 100, 100, 114, 101, 115, 115, 62, 13, 10, 60, 47, 115, 111, 97, 112, 58, 66, 111, 100, 121, 62, 13, 10, 60, 47, 115, 111, 97, 112, 58, 69, 110, 118, 101, 108, 111, 112, 101, 62, 13, 10]} [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 TCP connection [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 Key updated to 5 [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 TCP wrote 554 bytes [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 TCP write empty [Network IO] DEBUG com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 Key updated to 1 [Network IO] ERROR com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 Exception encountered java.io.IOException: An existing connection was forcibly closed by the remote host at sun.nio.ch.SocketDispatcher.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:197) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) at com.offbynull.portmapper.gateways.network.NetworkRunnable.handleSelectForTcpChannel(NetworkRunnable.java:166) at com.offbynull.portmapper.gateways.network.NetworkRunnable.run(NetworkRunnable.java:112) at java.lang.Thread.run(Thread.java:745) [Network IO] ERROR com.offbynull.portmapper.gateways.network.NetworkRunnable - 30 Exception encountered java.io.IOException: An existing connection was forcibly closed by the remote host at sun.nio.ch.SocketDispatcher.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:197) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) at com.offbynull.portmapper.gateways.network.NetworkRunnable.handleSelectForTcpChannel(NetworkRunnable.java:166) at com.offbynull.portmapper.gateways.network.NetworkRunnable.run(NetworkRunnable.java:112) at java.lang.Thread.run(Thread.java:745)
After this i get like a million of these IOExceptions, and the number 30 turns to 31 then to 32. Any ideas?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/offbynull/portmapper/issues/26#issuecomment-231116068, or mute the thread https://github.com/notifications/unsubscribe/AGD4Io3aH_XLn7toXjYNvikzmdTbQ22Vks5qTRykgaJpZM4JHLgd .
Its got 40MB, here's the link
Thanks.
I'll try to take a look when I get home tonight. On Jul 7, 2016 9:33 AM, "lpetrovic05" notifications@github.com wrote:
Its got 40MB, here's the link https://drive.google.com/file/d/0B5Nzdl3NNg8Oc3hOOVMxOExXUFk/view?usp=sharing
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/offbynull/portmapper/issues/26#issuecomment-231134236, or mute the thread https://github.com/notifications/unsubscribe/AGD4IlLfvNqb6jDaEKLv0i0ECjchKskIks5qTSpVgaJpZM4JHLgd .
Is your cisco router connected to the Internet (has an external IP assigned to it) when you try to port map? Or is it just providing connectivity between hosts on your internal network?
Its connected to the internet and has a public IP On Jul 7, 2016 10:03 PM, "Kasra Faghihi" notifications@github.com wrote:
Is your cisco router connected to the Internet (has an external IP assigned to it) when you try to port map? Or is it just providing connectivity between hosts on your internal network?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/offbynull/portmapper/issues/26#issuecomment-231190877, or mute the thread https://github.com/notifications/unsubscribe/ATJZCfwKBBgu2zXeDPrA6U83GVE0E45Kks5qTVuOgaJpZM4JHLgd .
With PortMapper, when you try to open a port it'll first make a request to grab your public IP address.
Just from looking at the logs, it seems the router may not like that request. The router disconnects the socket as soon the library asks for your public IP. Normal behaviour would be to respond with an error of some kind instead of a hard disconnect.
Can you confirm that you can successfully get your public IP via cling?
I can get my public IP using cling On Jul 7, 2016 10:53 PM, "Kasra Faghihi" notifications@github.com wrote:
With PortMapper, when you try to open a port it'll first make a request to grab your public IP address.
Just from looking at the logs, it seems the router may not like that request. The router disconnects the socket as soon the library asks for your public IP. Normal behaviour would be to respond with an error of some kind instead of a hard disconnect.
Can you confirm that you can successfully get your public IP via cling?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/offbynull/portmapper/issues/26#issuecomment-231204081, or mute the thread https://github.com/notifications/unsubscribe/ATJZCQhN_LvGPhZsQ8Wri6yZeyW8vwMQks5qTWddgaJpZM4JHLgd .
It's tough to say what the issue is here. The request being passed in to your router is valid. The headers are all correct and the SOAP message is correct as well.
My only guesses at the moment are that your router is expecting something different. For example, it ...
Without access to the router I can't really do much other than make vague guesses as to this specific router's quirks. I'm going to try to see if I can find your specific model of Cisco router (Cisco EPC3925) for purchase somewhere. If I can get my hands on one I may be able to workaround/fix the issue.
It may take a while before this is fixed. Please leave the ticket open.
POST /WANIPConnection HTTP/1.1
Host: 192.168.0.1:80
Content-Type: text/xml
SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 310
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
</u:GetExternalIPAddress>
</soap:Body>
Forgot to mention: if you can get wireshark logs of a successful UPnP port mapping on your router, that may help as well.
After some wiresharking and trying, I figured out that there are 3 things about your request that my router doesn't like for some reason. The first thing is the newlines after XML tags, the whole XML should be without newlines. The second is the SOAP namespace, you are using http://www.w3.org/2003/05/soap-envelope/ and Cling uses http://schemas.xmlsoap.org/soap/envelope/. The last thing is you are missing a closing tag for Envelope.
Here is your request with the 3 fixes that works on my router:
POST /WANIPConnection HTTP/1.1
Host: 192.168.0.1:80
Content-Type: text/xml
SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress
Connection: Close
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 297
<?xml version="1.0"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><soap:Body><u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"></u:GetExternalIPAddress></soap:Body></soap:Envelope>
Here is the Cling request:
POST /WANIPConnection HTTP/1.1
USER-AGENT: Windows7/6.1 UPnP/1.0 Cling/2.0
Content-type: text/xml;charset="utf-8"
Soapaction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress"
Host: 192.168.0.1
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: close
Content-Length: 291
<?xml version="1.0" encoding="utf-8" standalone="yes"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"/></s:Body></s:Envelope>
Thank you so much for debugging this.
The closing envelope tag is there. I may have missed the last line when I was copy-and-paste'ing.
I'm going to modify the code to remove the \r\n's and use the secondary namespaces if the first namespaces produce an error.
I'll try to get the changes in soon -- will need you to give it a try once it's ready.
Sorry for the delay.
I made 2 new commits. The first one removes the new lines. The second one changes the namespace and encoding style headers (it turns out the ones you posted are the correct ones).
I'm going to cut a new release tonight.
Release cut. Version 2.0.3 should be available from download Maven central soon.
Give it a try when you get a chance and let me know how it works for you.
It works now, thanks a lot
Hi, I have a Cisco uPNP router and I'm currently using Cling library to open ports and it works fine. I tried using portmapper with the example given and I got the following exception:
Do you have any idea what the problem is? Any tips on how to debug it?