Welcome to Live View – Take the tour to learn more
Start Tour
There is currently 1 person viewing this thread.
06 Jul 18 16:39
Date Joined: 27 Dec 11
| Topic/replies: 2 | Blogger: Natty's blog
Hi Folks.

My Bertfair Bot has been ticking along now for some time. However, in recent months - and more prevalent lately - I am getting INVALID_SESSION_INFORMATION errors, the result of which is that my program doesn't connect to the Betfair site. I've tweaked the code once in a while, but not touched the Session ID and Application Key part.

If I go into the demo app online, I can see the application key, which is the same as that in the program. Has something changed recently, can anyone tell me, or is there something I need to do to the code? It's getting very annoying!


Share |
Pause Switch to Standard View INVALID_SESSION_INFORMATION Error
Show More
Report Natty July 6, 2018 6:24 PM BST
Having looked at the code and debug, it appears that the SSOID is blank. The response is prefixed by wsid.

This is my code, which I got some time ago from the forum:

            ' initialise ssoid. This is used to get the Session Token information and needs to be reset if there are issues
            ssoid = ""

            ' Connect to betfair
            Dim uri As String = String.Format("{0}&passwo... sUsername, sPassword)
            Dim myRequest As HttpWebRequest = DirectCast(WebRequest.Create(uri), HttpWebRequest)
            myRequest.Method = "POST"
            myRequest.Timeout = 50000
            Dim thePage As WebResponse = myRequest.GetResponse()
            info = thePage.Headers.GetValues("Set-Cookie")
            Dim i As Integer = 0
            While ssoid = [String].Empty AndAlso i < info.Length
                If info(i).Contains("ssoid=") Then
                    ssoid = info(i)
                End If
                i += 1
            End While

            'This returns
            ' ssoid=KY8FBhBU26jP3M9EDE4NogOm9XfH5xJDR49BlJI0lac=;; Path=/
            sSessToken = ssoid.Replace("ssoid=", "") 'Dump front string
            sSessToken = sSessToken.Replace(";; Path=/", "") 'dump rear string

Thanks for any help with this!
Report jabe July 7, 2018 3:52 AM BST
It appears that I had something similar in the past.

As far as I can recall, when my program attempts to log in, for some reason it goes through the cookie code twice. The first time might be some sort of initialisation. I've had this kind of thing happen in a few sections in VB.NET. If I remember correctly, code that is triggered by a particular event seems to get triggered during initialisation - not by the specified event - and then again, later, when the actual event fires. I don't understand why, but I can tell you how I dealt with it in this instance.

My program is in VB.NET. My code where the cookies are checked is in a subroutine called WebBrowser1_DocumentCompleted.

First, it checks the cookies in a loop similar to yours.

Next, it deals with the ssoid, but ONLY IF THE SSOID IS NOT BLANK. If the ssoid is blank, the subroutine ends. The next time the subroutine is entered, the ssoid is not blank, and therefore relevant initialisation and transfer of control happens. This is my code subsequent to the cookie check, but with some removed where it sends a message to the main program (to display the ssoid on a messages tab):

         If Not ssoid = "" Then
            Form1.ssoid = ssoid  ' copy ssoid to main form variable
       ' next two lines store the ssoid as a text file for when the prog is next restarted
            Dim ssoidFileName As String = "ssoidFile.txt"
            My.Computer.FileSystem.WriteAllText(ssoidFileName, ssoid, False)
            Form1.Initialise()  ' starts the ball rolling on the main form
            Me.Close()  ' login window no longer required
        End If

    End Sub
Post Your Reply
<CTRL+Enter> to submit
Please login to post a reply.


Instance ID: 13539

New to Betfair?

You need to open an account before you can add content to the forum.

Opening an account only takes a few minutes.

register now