Author Topic: [SOLVED] UPnP Device Support / Gateway: none found  (Read 2960 times)

tehshawn

  • Guest
[SOLVED] UPnP Device Support / Gateway: none found
« on: February 26, 2013, 06:28:05 PM »
I noticed that TNet wasn't successfully understanding the UPnP packets sent from my router, and subsequently wasn't able to open the right ports. (D-Link DIR 655)
ArenMook, here was the fix for my case.

In TNUPnP.cs, on line 197 in the ParseResponse function
  1. int index = response.IndexOf("LOCATION:");
Most of the devices I've spotted on the two networks I've tested actually respond with "Location:" so I added that as an additional check on line 198 like this
  1. if (index == -1) index = response.IndexOf("Location:");

If anyone else encounters "Gateway: none found", here is how you may be able to help report it. Keep in mind the line numbers mentioned may change when ArenMook next updates the source code.
  • First ensure that you've restarted the application after allowing public and private network access through the automatic Windows firewall dialog that appears. If that wasn't it, you will need to add some "Console.WriteLine" statements into the TNet source code so you can report how your device differs:
  • Find the TNetServer.zip file that came with the asset store package and extract it somewhere.
  • In the place where you extracted it, Create an "Assets" folder, and within that create a "TNet" folder.
  • Copy the folders "Common" and "Server" from the asset store package into the TNet folder you just created.
  • Open up TNServer.sln with MonoDevelop or Visual Studio.
  • If you used MonoDevelop like I did at the time, you will need to comment out some extra lines or it will enter an infinite loop because MonoDevelop can't use Console.ReadLine. Open TNetTest>ServerMain.cs and comment out the lines inside the empty for loop from 155-156 located in the Start function.
  • Open up Assets>TNet>Common>TNUPnP.cs from the solution explorer in your chosen IDE.
  • Find the ParseResponse function and add something like this in the beginning of the function:
  1. Console.WriteLine("------------------------UPnP Response:\n" + response);
  • Find the GetControlURL function and add something like this after the null string check. I added this to the third line of the function:
  1. Console.WriteLine("+++++++++++++++++++UPnP Control:\n" + response);
  • Press F5 to run the app and grab the UPnP responses from your network devices. If you don't want to share your data with the world, private message it to the TNet author ArenMook.
« Last Edit: February 26, 2013, 07:36:51 PM by tehshawn »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [SOLVED] UPnP Device Support
« Reply #1 on: February 26, 2013, 07:09:45 PM »
Thanks for the bug report and the fix. I'm actually going to fix it slightly differently... like so:
  1. int index = response.IndexOf("LOCATION:", StringComparison.OrdinalIgnoreCase);