Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
VB
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:
VB
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)

VB
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 :-)

Chris
Posted

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 :-)
 
Share this answer
 
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???
 
Share this answer
 
You may be on to something there :-)

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
 
Share this answer
 
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)
 
Share this answer
 
Comments
[no name] 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.
[no name] 28-Nov-12 17:21pm    
I added some more info above about sending your request
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
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900