Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi All,
 
I have an unusual problem with httpListener (i think)
 
I've written a UPnP Media server and to extend it's capabilities i've written UPnP Relays that extend the primary service to other remote networks (it basically just proxies the requests back to the main server, to fool the client into bellieving its locally hosted content)
 
With audio it works beautifully, but video simply refused to stream, i've finally found the reason
 
Look at these 2 sets of headers, One is what the local network see's, the other is Remote
 
Local connections:
TransferMode.DLNA.ORG: Streaming
Accept-Ranges: bytes
Content-Length: 700631040
Content-Type: video/x-msvideo
Date: Wed, 28 Nov 2012 16:43:55 GMT
Server: Microsoft-HTTPAPI/2.0
 
Remote Connections:
TransferMode.DLNA.ORG: Streaming
Accept-Ranges: none
Content-Length: 700631040
Content-Type: video/x-msvideo
Date: Wed, 28 Nov 2012 16:44:58 GMT
Server: Microsoft-HTTPAPI/2.0
 
As you can see, the Accept-Ranges header is being changed by something and i cant figure out what's changing it and why
 
If somebody can confirm that its a limitation of the HttpListener Class then i'll write my own http server class, but why reinvent the wheel when you dont have to?
 
For reference, heres the code making the requests (only gathers the headers)
 
Dim req As HttpWebRequest = HttpWebRequest.Create(url)
Dim res = req.GetResponse
For Each h As String In res.Headers
    Console.WriteLine(h & ": " & res.Headers(h))
Next
 
All Advice/Help appreciated Smile | :)
 
Chris
Posted 28-Nov-12 6:52am
Anetics329
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Based on your content length I assume that you are gettin the same data in each case, I suggest you decode them similarly. I also found this on line :-
 
Quote:
14.5 Accept-Ranges
The Accept-Ranges response-header field allows the server to
indicate its acceptance of range requests for a resource:
Accept-Ranges = "Accept-Ranges" ":" acceptable-ranges
acceptable-ranges = 1#range-unit | "none"
Origin servers that accept byte-range requests MAY send
Accept-Ranges: bytes
but are not required to do so. Clients MAY generate byte-range
requests without having received this header for the resource
involved. Range units are defined in section 3.12.
Servers that do not accept any kind of range request for a
resource MAY send
Accept-Ranges: none
to advise the client not to attempt a range request.

 
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html[^]
 
There is another option that you can look at, Service Point Manager Call Back, place this in your code and debug through it
 
http://msdn.microsoft.com/en-us/library/system.net.security.remotecertificatevalidationcallback.aspx[^]
 
if you are getting an error on the server trust then you can set the call back to return true to trust all remote servers
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi, thanks for the reply,
 
Yes the same data is being sent in each case but as this is a stream server the "Accept-Ranges" header is crucial to allow avi streaming
 
In respect of the quote, i'm not really sure where its relevant, in both cases its the same server responding to exactly the same request, just that one is from a local area network and one is from a remote network
 
I need to determine what is changing the "Accept-Ranges" header, The "HttpListener" or something else inbetween
 
I also want to mention that my firewall is a sonicwall (just in case it's relevant, i dont think it is though)
 
If its the HttpListener then its simple, i'll write my own, but dont want to do it if i dont have to (yeah lazy i know)
  Permalink  
Comments
Mathlab at 28-Nov-12 17:17pm
   
Well if your client is not trusted then you could get that response header back with none, have you looked at your service point manager call back to see if your getting a trust error.
Mathlab at 28-Nov-12 17:21pm
   
I added some more info above about sending your request
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You may be on to something there Smile | :)
 
Just wrote a very basic http server and got exactly the same result, Even when trying "Accept-Ranges: bananas" it still got changed to "Accept-Ranges: none", so i think you may be correct, i'll test and report back
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Theres no error, it doesnt even fire the callback
but the relays are not ssl so i didnt really expect any errors
 
At this time i'm thinking of a simple "hack" of just detecting the presence of the "Accept-Ranges" header and override it back to "bytes" inside the relay code, it'll give me a bit of breathing space to figure out the real issue
 
I just cant get my head around why it would get changed???
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

I've ended up having to write my own http service (to ensure the headers are not being tampered with)
 
I've also written the relay to use pure sockets (no httplistener or HttpWebRequest) and running a manipulation on the Accept-Ranges header to correct it if preset
 
So far so good, its working perfectly Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,105
1 DamithSL 5,079
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,617
4 Kornfeld Eliyahu Peter 4,384


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100