Media Companion
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Media Companion

Discussion and development board for the program Media Companion.
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 Help wanted with an old issue

Go down 
3 posters
AuthorMessage
StormyKnight
VIP
VIP



Posts : 556
Join date : 2008-10-08
Location : Australia

Help wanted with an old issue Empty
PostSubject: Re: Help wanted with an old issue   Help wanted with an old issue Icon_minitimeMon Oct 12, 2009 2: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
Back to top Go down
billyad2000
Admin
billyad2000


Posts : 1326
Join date : 2008-09-20

Help wanted with an old issue Empty
PostSubject: Re: Help wanted with an old issue   Help wanted with an old issue Icon_minitimeSat Oct 10, 2009 12:25 pm

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

Thanks, I'll try that.
Back to top Go down
http://billyad2000.co.uk
wodi666
Junior Member
Junior Member



Posts : 17
Join date : 2008-10-15

Help wanted with an old issue Empty
PostSubject: Re: Help wanted with an old issue   Help wanted with an old issue Icon_minitimeFri Oct 09, 2009 10: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
billyad2000
Admin
billyad2000


Posts : 1326
Join date : 2008-09-20

Help wanted with an old issue Empty
PostSubject: Help wanted with an old issue   Help wanted with an old issue Icon_minitimeFri Oct 09, 2009 8: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.
Back to top Go down
http://billyad2000.co.uk
Sponsored content





Help wanted with an old issue Empty
PostSubject: Re: Help wanted with an old issue   Help wanted with an old issue Icon_minitime

Back to top Go down
 
Help wanted with an old issue
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Media Companion :: Media Companion :: Program Development-
Jump to: