Giter Site home page Giter Site logo

yortw / rssdp Goto Github PK

View Code? Open in Web Editor NEW
279.0 26.0 66.0 14.7 MB

Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network.

Home Page: http://yortw.github.io/RSSDP/

License: MIT License

Smalltalk 4.95% C# 94.01% Batchfile 0.04% JavaScript 0.99%
sdp service-discovery service-discovery-protocol c-sharp upnp discovering-devices

rssdp's People

Contributors

gfichter avatar jay18001 avatar kakone avatar kasitoru avatar lukepulverenti avatar martinwiboe avatar pelengami avatar petermajor avatar tapanila avatar yortw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rssdp's Issues

Empty custom properties break the description parser

If the server returns a document with an empty custom property, the parsing completes too early. This means that further properties are not read.

For example, assume we get this response from the server:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
  <specVersion>
    <major>1</major>
    <minor>0</minor>
  </specVersion>
  <device>
    <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>
    <UDN>uuid:55076f6e-6b79-1d65-a472-00059a3c7a00</UDN>
    <friendlyName>Twonky :)</friendlyName>
    <pv:extension xmlns:pv="http://www.pv.com/pvns/"></pv:extension>
    <manufacturer>PacketVideo</manufacturer>
    <manufacturerURL>http://www.pv.com</manufacturerURL>
    <modelName>TwonkyServer</modelName>
    <modelURL>http://www.twonky.com</modelURL>
    <modelDescription>TwonkyServer (Windows, T-206)</modelDescription>
    <modelNumber>8.4</modelNumber>
    <serialNumber>8.4</serialNumber>
  </device>
</root>

Properties after the empty <pv:extension> tag (starting with manufacturer) will not be initialized. This seems to be a bug in SsdpDevice.AddCustomProperty where the XmlReader is advanced too far in the document.

Rssdp Shared

I have included nuget package into my project (portable library), but I don't see classes from Shared folder, Am I doing something wrong?

Installing the Nuget package in a new Android project does not add correct references

We have been using the 2.0.0.1 version of RSSDP, installed through Nuget, and it worked flawlessly. However, the project cannot be built after installing the newest version (3.0.2).

When building the project, the following error occurs:

The type 'SsdpDeviceLocator' is defined in an assembly that is not referenced. You must add a reference to assembly 'Rssdp.Native, Version=3.0.2.0, Culture=neutral, PublicKeyToken=null'.

This also occurs when adding the package in an empty project. I have created a small repro project: https://www.dropbox.com/s/thft4y00frnw1pu/DlnaPlayground.7z?dl=0

Possible to default Location to something automatically?

First of all this stuff works pretty well I must say.

I know this might be that the specs are just this way, but the way I want to use the SsdpPublisher, is a bit more dynamic than those examples. Ideally I'd fire this app up on my hardware, and have it use public ip for the location url plus some route postfix. The problem is I don't necessarily know ahead of time what that might be. (didnt know if there was a way within the library to say when we get an inbound request we might be able to determine what ip it came into or something).

Also, if I'm building out a device definition to publish, is there a way I can get a xml file from that?

SSDP not discovered

Hello,
I'm publishing my application using RSSDP in windows 7.
When i try to discover the app by the RSSDP discovery- it works only if the discovery code is within the same published application. :/

I use IPV4, I have no firewall and I tried to disable/enable the SSDP/UPNP service, but it didn't help.
My goal is to find the published app by any of the Upnp scanners in the lan (right now it does not work).

I'd really appreciate your help,
Eyal.

Missing MX/Man Support

Some devices do not send MX/MAN headers in search requests. The SSDP specification says messages missing these should be ignored, however this just leads to a system that doesn't work.

Suggested solution is to add a StandardsMode property to the SsdpPublisher of an enum type (SsdpStandardMode) with one of the following options;

  • Default - probably should be treated as 'Relaxed' so it just works out of the box for most consumers.
  • Strict - Strictly obeys the standard, ignoring requests missing the required headers.
  • Relaxed - Uses a sensible default when the MX/MAN headers etc are missing.

It is further suggested that if other standard vs. reality issues occur this same flag is used to determine appropriate behaviour. A similar property may also be added to the SsdpDeviceLocator in the future if similar problems are found in that area.

Android Support

Would love for the library to support Android. In theory it's easy, since System.Net.Sockets should be supported by Xamarin on Android. All we should need to do is;

  1. Create a new Android class library project, link in/setup the relevant assemblyinfo files.
  2. Link in the shared files for System.Net.Sockets support (basically link in same files as in the iOS project).
  3. Test it.
  4. Update the nuget package etc. to support the new lib.

I have a problem doing this primarily because I have no android devices to test with, and also some minor licensing issues with Xamarin Android. If someone else wants to do this, I'd appreciate it.

SsdpDevicePublisher not available for Xamarin?

Hi and thanks for your great work.

I use rssdp and SsdpDevicePublisher with success in a windows (uwp) app. Now I want to use it on IOS/tvOS using Xamarin (Visual Studio for Mac).

However, the class SsdpDevicePublisher does not exist in this environment. All other classes exist, and I can use SsdpDeviceLocator with success.

I use version 3.5.7

Any ideas on why SsdpDevicePublisher is not available?

No results returned for searches on Windows 10

This may be a general Windows 10 issue as I've seen a number of complaints about 3rd party UPNP/SSDP libraries not working on Windows 10, but I cannot seem to get any response to searches.

Using my Android phone I get a quick list of various UPnP devices on the network using an app called UPnP Tool. And on my Windows 10 laptop I can install a Windows Store app called SSDP Scanner which seems to work. But nothing I've done in C# so far (.NET 4.5 console app) has been able to turn up any results.

Wondering if this is an anomaly on my system or something more serious.

PCL support

If I would do a pull request to support PCL development using Bait and Switch would you accept that?

Cannot publish or search on macOS/Linux using .NET Core

I have just run into this issue Cannot set udpClient.ExclusiveAddressUse = false in macOS and Linux whilst testing the .NET Standard library on non-Windows platforms.

This actually prevents publishing/searching altogether as you get an exception:

Unhandled Exception: System.Net.Sockets.SocketException: Operation not supported
at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent)
at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)
at System.Net.Sockets.Socket.set_ExclusiveAddressUse(Boolean value)
at Rssdp.SocketFactory.CreateUdpMulticastSocket(String ipAddress, Int32 multicastTimeToLive, Int32 localPort)

However, changing the code from SocketFactory.cs#L87 as follows:

#if NETSTANDARD1_3
    if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
    {
        retVal.ExclusiveAddressUse = false;
    }
#else
    retVal.ExclusiveAddressUse = false;
#endif

Allows publishing and searching, but until the Rework ExclusiveAddressUse and ReuseAddress on non-Windows platforms commit makes in into a release, a simultaneous publish and search will throw an 'Address in use' exception on non-Windows platforms.

Method not found: 'Void System.Net.Http.HttpClientHandler.set_AutomaticDecompression(System.Net.DecompressionMethods)'.

I'm getting the exception:

Exception thrown: 'System.MissingMethodException' in Rssdp.Portable.dll ("Method not found: 'Void System.Net.Http.HttpClientHandler.set_AutomaticDecompression(System.Net.DecompressionMethods)'.")

...when using the "Event Driven Search & Discovery via Notifications" approach.

The exception is thrown as this line is executed: var fullDevice = await e.DiscoveredDevice.GetDeviceInfo();. The line isin the deviceLocator_DeviceAvailable method as per the example provided in the Readme.md.

Any ideas what this could be?

Some of the devices discovered are fine but others result in this error.

I'm not running the Nuget, but have cloned the code base locally. I'm running this on a Windows 10 PC in an UWP App. I'm referencing the projects:

  • RSSDP.Portal
  • Rssdp.UWP10

If I'm using only the Nuget I'm also getting exception, but they point to some XML parsing error???

Core CLR Support

We should make this run on Core CLR/DNX/whatever it's called these days and update the nuget package so it just works for these types of projects.

Support for LF terminators

I had an exception in HttpParserBase

data is not a valid request, it does not contain any CRLF terminators

Upon inspection it appeared the incoming data was split with a LF rather than CRLF.

How create Location file and share

How create location file and share it on the UWP(Windows 10)
I don't know how right share file throw network.
Unfortunately I cannot find it in the description

Net Core functionality

So, I just today grabbed latest net core package (2.0.0.4) which installed and appears to start and broadcast if I'm listening with the sample app... but searching is all but broke (even if using the sample to publish, and immediately turn around and search with appropriate UUID - p in the command line, then u)

Search never appears to find anything, and I see a lot of errors that look like this;

'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Private.Uri.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.ObjectDisposedException' in System.Net.Sockets.dll
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.ni.dll
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.ni.dll
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Runtime.InteropServices.RuntimeInformation.dll'. Cannot find or open the PDB file.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\System.Reflection.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
The thread 0x7ed0 has exited with code 0 (0x0).
Exception thrown: 'System.ObjectDisposedException' in System.Net.Sockets.dll
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.ni.dll
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.ni.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll

Trying to dig in further, best I can tell is that some of the aggregate exceptions originate here:

Rssdp.NetCore.dll!Rssdp.UdpSocket.ProcessResponse(AsyncReceiveState state = {unknown}, System.Func<int> receiveData = {unknown})    

Bound to wrong IPAddress

Hello,

_Socket.Bind(new IPEndPoint(IPAddress.Any, _LocalPort) can bind sometimes to a wrong network address (on my computer, I have several network cards and sometimes, it choose the wrong local IP address). In the documentation of Socket.Bind method, you can see : "using IPAddress.Any as the address parameter, and the underlying service provider will assign the most appropriate network address".
So I replaced by _Socket.Bind(new IPEndPoint(Dns.GetHostAddresses(Dns.GetHostName()).Where(address => address.AddressFamily == AddressFamily.InterNetwork).First(), _LocalPort)); because the first IPAddress is the good one for me but the good solution would be to create an UdpSocket for each local IP address.

Cordially,
Stéphane.

Publish gets stuck a while

Hi Yortw,
I'm publishing upnp by a windows service.
I'm running the following code every x seconds:

var deviceDefinition = new SsdpRootDevice()
{
    CacheLifetime = 30,
    Location = G.Location,
    DeviceTypeNameSpace = G.DeviceTypeNamespace,
    DeviceType = G.DeviceType,
    FriedlyName = G.FriendlyName,
    Manufacturer = G.Manufacturer,
    ModelName = G.ModelName,
    Uuid = G.Uuid
}

_Publisher = new SsdpDevicePublisher();
_Publisher.AddDevice(deviceDefinition);

It works great for a while, but after about 2,000 times- it gets stuck on the "_Publisher.AddDevice".
It does not respond even to a Thread.Abort(), so i can't even handle this as an exception.

Why does it happen:question: :/

IPV6 support

Hello,

It lacks IPV6 support (multicast address : FF02::C).

Cordially,
Stéphane.

Question: How to publish services?

Consider this example

NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://10.0.0.1:64321/DmsDesc.xml
NT: urn:schemas-upnp-org:service:ConnectionManager:1
NTS: ssdp:alive
SERVER: Linux/2.6 UPnP/1.0 NEX-6/1.0
USN: uuid:00000000-0000-0010-8000-2002af0fa742::urn:schemas-upnp-org:service:ConnectionManager:1

FullDeviceType has the text device hard-coded:

public string FullDeviceType

In my fork I added a DeviceClass string property which defaults to device but can be customized to service.

Am I correct that without this there is no way for RSSDP to broadcast an alive message for this? The publishing example does not included embedded devices so I wasn't sure. If this is not currently supported then I can submit a pull request. Thanks.

Alive Notification Broadcast Interval

Some client applications would like to control how often alive notifications are sent, rather than relying on the randomised interval suggested by the SSDP specification.

Suggested solution: Add a 'NotificationBroadcastInterval' property of type TimeSpan to the SsdpDevicePublisher with a default value of TimeSpan.Zero. A value of TimeSpan.Zero will default to the existing randomised behaviour. Any other value will be used as a repeating interval from start of the publisher.

Questions:

  • The SSDP specification specifies a minimum broadcast interval (15 minutes?) - should values less than this be ignored/generate an error?

  • With the property being present on the publisher rather than individual devices seems easy to manage and probably all that is required, however moving the property to the device class would allow different intervals for different devices. This would also increase the complexity of the broadcast scheduling logic slightly.

Can't discover device using SsdpDeviceLocator

Hi,

So, I've got an application running that publishes itself using SsdpDevicePublisher. I have another application running SsdpDeviceLocator.

Now when I just run both these apps from the same windows machine the locator discovers the publisher. However, if I run the publisher on a raspberry pi (via mono) I can't see it from the locator.

Any thoughts on why this might be?

The odd thing is that windows can see the raspberry pi service as it shows up in my network folder!

Microsoft.Bcl.Build warnings and errors

I'm developing some sort of framework, which includes this one for the service discovery.
When referencing my framework from an end user project (WPF/UWP), I get warnings and errors. This come from Microsoft.Bcl.Build which is a dependency of RSSDP:

  • Error: Could not locate path/to/packages.config. Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file.
  • Warning: All projects referencing MyFramework.csproj must install nugget package Microsoft.Bcl.Build

I tried to suppress these warnings (see stackoverflow, but this just added another error:

  • The OutputPath property is not set for project...

Do you have any experiences with those?

System.AggregateException in Xamarin.iOS project

I am using your library in an Xamarin.iOS project and got the following exception. The exception only occured once until now and i can not reproduce it, so i think its a minor problem:
'System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.Net.Sockets.SocketException: The socket is not connected

The exception was thrown from the Rssdp.Infrastructure.SsdpCommunicationsServer.ListenToSocket() method.

I think a ContinueWith() could solve the problem:

var t = TaskEx.Run(async () =>	{ ... });
t.ContinueWith(t2 =>
{
    //ignore exceptions
}, TaskContinuationOptions.OnlyOnFaulted);

Dependencies

Because of support for older platforms such as .Net 4.0 and WP 8.0, RSSDP has a dependency on the Async/BCL libraries from Microsoft. These dependencies are not neccesary on newer platforms.

Now that RSSDP uses the bait and switch technique, it should be possible to create a PCL supporting only the newer platforms and drop the dependencies from both the referenes and the nuget target for those platforms while keeping them for the older ones.

Given the BCL libs are somewhat cancerous, in that anything that if project A reference project B and project B references the BCL, then project A (and anything referencing it) also needs to reference BCL or suffer compiler warnings, dropping the dependencies where not required would be a great idea.

Alive Notification Not Upper-Casing Date Header

As per the title, the Date HTTP header in an alive notification is not uppercase. While technically allowed by the relevants specifications, some devices may do a case insensitive comparison and fail. Change the header so it's always upper case to avoid potential compatibility.

Simple UDP discovery code works but RSSDP example does not

I have a bunch of devices on my network that publish about 25 services with SSDP. Devices include a Synology DiskStation and a couple of Samsung TVs among others.

When I tried to run the RSSDP example (commands: A, R and B) to search for All, Root or Basic devices - it doesn't find anything. I used command L to listen before searching. I also attempted to change the example to use a specific local address as noted in your solution here, but that did not work either:

Change to line 105 of RSSDP/src/Main/Rssdp.Samples/Program.cs:

_BroadcastListener = new SsdpDeviceLocator(
    new Rssdp.Infrastructure.SsdpCommunicationsServer(
        new Rssdp.SocketFactory("192.168.1.99")
    ));

However, the following UDP code for SSDP discovery from this stackoverflow post works after I applied the advice from all three answers... My final code is shown below and when I run it, I get about 240 lines of console output showing the responses from all my devices...

IPAddress localNetwork = Dns.GetHostAddresses(Environment.GetEnvironmentVariable("COMPUTERNAME")).Where(ia => (ia.AddressFamily == AddressFamily.InterNetwork)).First();
IPEndPoint LocalEndPoint = new IPEndPoint(localNetwork, 60000);
IPEndPoint MulticastEndPoint = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 1900);
//IPEndPoint MulticastEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.255"), 1900);

Socket UdpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

//UdpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
UdpSocket.Bind(LocalEndPoint);
//UdpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(MulticastEndPoint.Address, IPAddress.Any));
//UdpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 2);
//UdpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback, true);

Console.WriteLine("UDP-Socket setup done...\r\n");

string SearchString = "M-SEARCH * HTTP/1.1\r\nHOST:239.255.255.250:1900\r\nMAN:\"ssdp:discover\"\r\nST:ssdp:all\r\nMX:3\r\n\r\n";

UdpSocket.SendTo(Encoding.UTF8.GetBytes(SearchString), SocketFlags.None, MulticastEndPoint);

Console.WriteLine("M-Search sent...\r\n");

byte[] ReceiveBuffer = new byte[64000];

int ReceivedBytes = 0;

while (true)
{
    if (UdpSocket.Available > 0)
    {
        ReceivedBytes = UdpSocket.Receive(ReceiveBuffer, SocketFlags.None);

        if (ReceivedBytes > 0)
        {
            Console.WriteLine(Encoding.UTF8.GetString(ReceiveBuffer, 0, ReceivedBytes));
        }
    }
}

Heartbeat

Hello, how can I piggy back a heart beat in this.

What should I do to configure the packets, so that I dont get my messages to get tagged into Dos packet.

Aggregate Publisher/Listener

Many consumers would like to listen/publish on multiple adapters/networks/addresses (whatever is the right term here). Rssdp doesn't support that, and there are architectural issues with trying to implement it given the current design.

To make life easier for consumers, could we; create an AggregateSsdpDevicePublisher (and possibly AggregateSsdpDeviceLocator) which take an IEnumerable of the associated type. Add a device to the aggregate publisher would add it to all internal publishers, and performing a search on the aggregate locator would union the search from all internal locators. Other properties and settings would also map down to the inner collections, allowing consumers to treat multiple instances as if they're a single instance.

There are some potential issues here, for example, with the locator what happens when one inner locator throws an exception on search? Does the user get the exception and no results, or the successful results and the exception is buried?

Calling SearchAsync produce random ObjectDisposedException as unhandled

Stack

>	System.Net.Sockets.dll!System.Net.Sockets.Socket.EndReceiveFrom(System.IAsyncResult asyncResult, ref System.Net.EndPoint endPoint)	Unknown
 	System.Net.Sockets.dll!System.Net.Sockets.SocketTaskExtensions.ReceiveFromAsync.AnonymousMethod__8_1(System.IAsyncResult asyncResult)	Unknown
 	System.Private.CoreLib.ni.dll!System.Threading.Tasks.TaskFactory<System.Net.Sockets.SocketReceiveFromResult>.FromAsyncCoreLogic(System.IAsyncResult iar, System.Func<System.IAsyncResult, System.Net.Sockets.SocketReceiveFromResult> endFunction, System.Action<System.IAsyncResult> endAction, System.Threading.Tasks.Task<System.Net.Sockets.SocketReceiveFromResult> promise, bool requiresSynchronization)	Unknown
 	System.Private.CoreLib.ni.dll!System.Threading.Tasks.TaskFactory<System.Net.Sockets.SocketReceiveFromResult>.FromAsyncImpl.AnonymousMethod__0(System.IAsyncResult iar)	Unknown
 	System.Net.Sockets.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken)	Unknown
 	System.Net.Sockets.dll!System.Net.ContextAwareResult.CompleteCallback()	Unknown
 	System.Net.Sockets.dll!System.Net.ContextAwareResult.Complete.AnonymousMethod__15_0(object s)	Unknown
 	System.Private.CoreLib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)	Unknown
 	System.Net.Sockets.dll!System.Net.ContextAwareResult.Complete(System.IntPtr userToken)	Unknown
 	System.Net.Sockets.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken)	Unknown
 	System.Net.Sockets.dll!System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped)	Unknown
 	System.Threading.Overlapped.dll!System.Threading.Win32ThreadPoolNativeOverlapped.OnExecutionContextCallback(object state)	Unknown
 	System.Private.CoreLib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)	Unknown
 	System.Threading.Overlapped.dll!System.Threading.Win32ThreadPoolNativeOverlapped.CompleteWithCallback(uint errorCode, uint bytesWritten, System.Threading.Win32ThreadPoolNativeOverlapped* overlapped)	Unknown
 	System.Threading.Overlapped.dll!System.Threading.ThreadPoolBoundHandle.OnNativeIOCompleted(System.IntPtr instance, System.IntPtr context, System.IntPtr overlappedPtr, uint ioResult, System.UIntPtr numberOfBytesTransferred, System.IntPtr ioPtr)	Unknown

I'm using RSSDP for Windows 10 UWP app.

My init code

foreach (var host in confirmedHosts)
            {
                var deviceLocator =
                    new SsdpDeviceLocator(new SsdpCommunicationsServer(new SocketFactory(host.CanonicalName)))
                    {
                        NotificationFilter = "urn:schemas-upnp-org:device:MediaServer:1"
                    };
                deviceLocator.DeviceAvailable += DeviceLocator_DeviceAvailable;
                deviceLocator.StartListeningForNotifications();
                deviceLocators.Add(deviceLocator);
            }

And the call

try
            {
                foreach (var dev in deviceLocators)
                {
                    await dev.SearchAsync();
                }
            }
            catch (Exception e)
            {
                Log.Debug(e);
            }

And handler

        private async void DeviceLocator_DeviceAvailable(object sender, DeviceAvailableEventArgs arg)
        {
            try
            {
                ....
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                Log.Error(e);
            }
        }

Removing the call stops unhandled exceptions

I have my own UDP receiver code using DatagramSocket and it has no such problem.

SSDP search on specific local ip not working

Hi,

first of all great project - works brilliantly although I have one problem with different networks and SSDP broadcasts.
So the scenario:
I'm connected to two different Wifi networks the same time - both are connections to Cameras (which run in hot spot mode). Sadly those cameras have both the same IP as you can't configure it while they run in hotspot mode...
I have identified the local IP endpoints which bind to the cameras - say 192.168.1.158 and 192.168.1.240.

If I perform a search as in your FAQ:

        private async Task<SsdpDevice> SearchForDeviceSsdp(string localIpEnpoint)
        {
            int localPort = _rnd.Next(50000, 55000); //seen here: https://github.com/Yortw/RSSDP/issues/38           
            Rssdp.Infrastructure.SsdpCommunicationsServer localPortServer = new 
            Rssdp.Infrastructure.SsdpCommunicationsServer(new Rssdp.SocketFactory(localIpEnpoint));
            using (var deviceLocator = new SsdpDeviceLocator(localPortServer), localPort)
            {
                deviceLocator.NotificationFilter = SONY_API_IDENTIFIER; //filters for the camera API
                try
                {
                    IEnumerable<DiscoveredSsdpDevice> foundCameraApi = await deviceLocator.SearchAsync();

                    var discoveredSsdpDevices = foundCameraApi as DiscoveredSsdpDevice[] ?? foundCameraApi.ToArray();
                    foreach (var foundDevice in discoveredSsdpDevices)
                    {
                        SsdpDevice fullDeviceInfo = await foundDevice.GetDeviceInfo();
                        return fullDeviceInfo;
                    }
                }
                catch (Exception e)
                {
                }
            }
            return null;
        }

I always get the same camera. So the DeviceInfo contains the name of the camera - I can see I always get the same ID. So I can't differentiate between those cams. On the other side I do later call the API of each camera individually - to take a photo - which works fine.

So I'm wondering if there could be an issue with search based on a locally bound IP.

So calling the API is a bit messy right now but the ServicePoint reset (or set to local IP) is basically this:

                ServicePoint servicePointG = ServicePointManager.FindServicePoint(new Uri(camera.CameraApiEndpoint));
                servicePointG.BindIPEndPointDelegate = (servicePoint, remoteEndPoint, retryCount) => new IPEndPoint(IPAddress.Parse(camera.LocalIpBindingEndpoint), 0);

                servicePointG.ConnectionLeaseTimeout = 0;

                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(camera.CameraApiEndpoint);
                req.ContentType = "application/json";
                req.KeepAlive = false;
                req.Method = "POST";
                req.Timeout = 10000;

So I'm kinda sure the communication is basically fine - just the SSDP on a specific locally bound IP does not work (but would be needed so I know which cam is which).
Currently the GetDeviceInfo call always returns exactly the same result - independent of the local IP (which shouldn't be the case).

Any help would be awesome.
Thanks
Nico

Publishing does not work on Xbox One

Hi!
I'm implementing ssdp publishing with RSSDP in a UWP / Windows 10 app for both desktop and Xbox.
I can publish successfully running on Windows 10, but on Xbox it does not work. I get no exceptions.
Any idea on why it does not work on the xbox device?

RSSDP on Uwp

I'm trying to use RSSDP on Uwp (planning to do something fun with win IoT)
When running the package, I get errors about IP addresses not being found. I forked and ran with the sources, and then I get an issue due to AutomacDecompression stuff.
Maybe this is due to portable libraries being used. I'd suggest using shared projects instead.

await DiscoveredDevice.GetDeviceInfo() fails

Calling GetDeviceInfo() in MessageReceived fails with HttpRequestException for some devices.
Inner exception is ComException without any message in System.Net.Http.HttpClientHandler.
Using it in UWP application.

After searching some info I found some solution about proper handling http redirection.

For now workaround is to ignore this exception.

Published SSDP Device Not visible on Local Network

I have successfully published the device in my console app.
The device is visible on the system running the console app. But on the other computers running on the same network the device is not being shown.

Accessing Custom Headers from DiscoveredSsdpDevice

I am not sure how to access the custom response headers defined in SsdpRootDevice from the DeviceAvailable callback. It appears they are not packed in the ResponseHeaders and every time I call GetDeviceInfo(), I get an HTTP exception.

Any guidance you can give is appreciated. Thanks.

Is it possible to specify a non-standard port number to this library?

Hello,

I've just bought a Xiaomi YeeLight wifi lightbulb. It offers an open API for geeks who knows how to programming on it. But I've checked their API document spec, it mentioned that they are using SSDP protocol with a non-standard port number, which is 1982 instead of standard port 1900. (See here: Yeelight spec (English))

So I would like to ask that, is it possible that I can use this library directly and specify the port number, instead of editing source code?

Thanks in advance!
Jackson

Network enumeration

Hi, how can I enumerate over the network in both IP v4 and and V6 and reconcile the discovery.

Support for different UDP port used for SSDP multicast messages

Hello,

Just wanted to ask if it would be a valid request to be able to define the port for multicast messages manually. The default port for SSDP is 1900 but the manufacturer of the device I wish to discover listens to 1982 port. As he states in his documentation:

Different from SSDP protocol, we choose to send multicast messages to port 1982 instead of standard SSDP port 1900. This is to avoid excessive multicast messages being received by both smart LED and 3rd party devices. It's especially important if the 3rd party device is power consumption sensitive (e.g. smart watch powered by battery).

I don't know if this is a common practice manufacturers decide to follow, but I am unable to use RSSDP because of that port decision. I didn't find anything in the source code that enables me to override the multicast port. Nevertheless as I stated that is the decision of a single manufacturer, that knowingly decided to differentiate from the SSDP protocol, so I am not sure if such a change to RSSDP would be worth it.

If you consider that adding the port as another user defined parameter does not offer any significant value, please close this issue.

Thank you

Device, published by RSSDP, is invisible on local network

If it's a duplicate, probably it's still not resolved yet.

I'm using UPnP-Pentest-Toolkit to test Rssdp.Samples (console program from master branch), also built the same program but with nuget package (to be 100% sure) - no "Sample RSSDP Device" visible on local network (and same happened with my real DLNA media renderer program).
By the way, I can find published device with SSDP code (another UPnP C# code from github) but looks like it's still messy for the standard SSDP browsers/devices.

I tried on the same PC running Windows 10, and on different PCs, Win10 and Win7 - same result, device is invisible...

Any advice please? Could you tell me, how to make your published device (from sample) visible in the UPnP-Pentest-Toolkit? (it has a precompiled binaries located here). WinUPnPFun utility works 100% correct with the other UPnP devices on my local network (better than Intel's utility - they can't find my smart TV).

P.S. I have a troubles to build https://github.com/nccgroup/UPnP-Pentest-Toolkit , to see what's happened inside (this assembly uses native C++ code). BTW, I'll keep trying to get debug build working and see, what's wrong with the RSSDP.

VS2015, Nuget & Xamarin Incompatibility

Due to an issue in either Nuget, VS2015 or the integration between them it is currently not possible to install the RSSDP nuget package into Xamarin projects (iOS or Android, presumably Mac too). The actual error occurs with the Microsoft.Async.Build package.

RSSDP will install into non-Xamarin projects in VS2015. It will also install into all supported project types (Xamarin included) when used from VS2013.

As it works in VS2013 this does not appear to be a problem with RSSDP itself, or it's nuget package. It appears we will have to wait for either Nuget or the relevant Microsoft packages to be updated to fix the issue.

I believe this is the relevant Nuget issue; NuGet/Home#1707

FAQ Needs Updating

  • Remove the bit about PCLS/bait and switch as this is supported now.
  • Update the search not working issue to discuss providing the specific IP Address to use, maybe include a sample.
  • Anything else that is out of date/could be improved.

Can't get it working

Will this project compile in VS2010 sp1? When I open the solution file I get lots of errors about most of the files not being compatible with this version. If a create a simple console project and reference the dll's in the packages folder visual studio complains because rssdp is compiled with .net 4.0.3 but it also wants a reference to system.net.http version 1.5 which isn't in .net 4.0.3. What am I missing here?

Signed assembly on NuGet

Could you provide signed assemblies via NuGet? We use an application that is signed and therefor requires signed assemblies.

Add Xamarin.Mac Support

I was looking to use this on a Xamarin.Mac. What steps would I need to take to add it?

Its looks like the only thing I have to do is add a new Xamarin.Mac project, create the platform specific SsdpDevicePublisher, link the associated files and update the Nuget packages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.