Media Companion

Discussion and development board for the program Media Companion.
HomeHome  ­FAQFAQ  ­SearchSearch  ­RegisterRegister  ­Log inLog in  
Post new topic   Reply to topicShare | 
 

 Help wanted with an old issue

View previous topic View next topic Go down 
AuthorMessage
StormyKnight
Senior Member
Senior Member


Posts: 204
Join date: 2008-10-08

PostSubject: Re: Help wanted with an old issue   Mon Oct 12, 2009 12:27 pm

Billy, whilst I don't think the cause of the timeout failure is the same as is mentioned in this code below, but latter the poster claims the timeout is now working, so perhaps the corrected code may assist.

http://www.dotnet247.com/247reference/msgs/21/106984.aspx

It looks like he is using a different syntax to create the wr object too.

Cheers

_________________
My Setup...
Using MC on XP SP3 32bit, Media is on NAS unit, XBMC on 2 XBOX's & 1 XP PC
Back to top Go down
View user profile
billyad2000
Admin


Posts: 890
Join date: 2008-09-20

PostSubject: Re: Help wanted with an old issue   Sat Oct 10, 2009 10:25 am

wodi666 wrote:
You can try to use a ServicePoint Connection, there you can use ServicePoint.MaxIdleTime / ServicePoint.ConnectionLeaseTimeout


Thanks, I'll try that.

_________________
Do you have a problem with Media Companion, before posting a bug then please check you have the very latest version of Media Companion http://billyad2000.darkbb.com/announcements-f1/
Back to top Go down
View user profile http://billyad2000.co.uk
wodi666
Junior Member
Junior Member


Posts: 17
Join date: 2008-10-14

PostSubject: Re: Help wanted with an old issue   Fri Oct 09, 2009 8:12 pm

You can try to use a ServicePoint Connection, there you can use ServicePoint.MaxIdleTime / ServicePoint.ConnectionLeaseTimeout

Code:

Dim instance As ServicePoint
Dim value As Integer

value = instance.MaxIdleTime

instance.MaxIdleTime = value



Code:

Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Public Class ServicePointExample

    ' Pass in the name of the Web page to retrieve.
    Public Shared Sub Main(ByVal args() As String)
        Dim page As String
        If args Is Nothing OrElse args.Length = 0 OrElse args(0).Length = 0 Then
            page = "http://www.contoso.com/default.html"
        Else
            page = args(0)
        End If

        Dim request As HttpWebRequest = CType(WebRequest.Create(page), HttpWebRequest)
        ' Get the service point that handles the request's socket connection.
        Dim point As ServicePoint = request.ServicePoint
        ' Set the receive buffer size on the underlying socket.
        point.ReceiveBufferSize = 2048
        ' Set the connection lease timeout to infinite.
        point.ConnectionLeaseTimeout = Timeout.Infinite
        ' Send the request.
        Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
        Dim responseStream As Stream = response.GetResponseStream()
        Dim s As New StreamReader(responseStream)
        ' Display the response.
        Console.WriteLine(s.ReadToEnd())
        responseStream.Close()
        response.Close()
    End Sub 'Main
End Class
Back to top Go down
View user profile
billyad2000
Admin


Posts: 890
Join date: 2008-09-20

PostSubject: Help wanted with an old issue   Fri Oct 09, 2009 6:21 pm

This is regards to an issue that is as old as MC and relates to what happens when a website such as TMDB or TVDB is down.

Here is an example of the code that is used;
Code:
            Dim wrGETURL As WebRequest
            wrGETURL = WebRequest.Create(url)
            Dim thisProxy As New WebProxy("thisproxy", 80)
            thisProxy.BypassProxyOnLocal = True
            Dim objStream As Stream
            objStream = wrGETURL.GetResponse.GetResponseStream()
            Dim objReader As New StreamReader(objStream)

            page = objReader.ReadToEnd


This works OK most of the time, the problem is when the "url" is not available for some reason. MC stands still until it times out which is way too long, I tried adding the following to the code;
Code:
            wrGETURL.Timeout = 5000

The idea being that the webrequest would timeout after 5 seconds, but it has no effect whatsoever
I could create a separate thread for each of these, but it would take a lot of time and code and is in my opinion, a very complicated solution for a simple problem.

Any help would be appreciated.

_________________
Do you have a problem with Media Companion, before posting a bug then please check you have the very latest version of Media Companion http://billyad2000.darkbb.com/announcements-f1/
Back to top Go down
View user profile http://billyad2000.co.uk
 

Help wanted with an old issue

View previous topic View next topic Back to top 
Page 1 of 1

Permissions of this forum:You cannot reply to topics in this forum
Media Companion :: Media Companion :: Program Development-
Post new topic   Reply to topic