Hey everyone,
I'm currently developing a program/bot for the Betfair API and have a question. I am still currently on the Delayed app key, however I was wondering about response times.
This is my code in VB.NET:
(Mostly taken from an example)
I'm finding using the timer its taking around 1.9 seconds to get a response from the server. I need this to be faster. Is it because I am using the delayed app key or because this is a slow method?
Is there a way to speed things up?
Thanks for your help!
I'm currently developing a program/bot for the Betfair API and have a question. I am still currently on the Delayed app key, however I was wondering about response times.
This is my code in VB.NET:
(Mostly taken from an example)
Code:
Function CreateRequest(AppKey As String, SessToken As String, postData As String)
Dim Url As String = "https://api.betfair.com/exchange/betting/json-rpc/v1/"
Dim request As WebRequest = Nothing
Dim dataStream As Stream = Nothing
Dim response As WebResponse = Nothing
Dim strResponseStatus As String = ""
Dim reader As StreamReader = Nothing
Dim responseFromServer As String = ""
Try
Dim TimerStart As DateTime
TimerStart = Now
request = WebRequest.Create(New Uri(Url))
request.Method = "POST"
request.ContentType = "application/json-rpc"
request.Headers.Add(HttpRequestHeader.AcceptCharset, "utf-8")
request.Headers.Add("X-Application", AppKey)
request.Headers.Add("X-Authentication", SessToken)
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
request.ContentLength = byteArray.Length
dataStream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
response = request.GetResponse()
strResponseStatus = CType(response, HttpWebResponse).StatusDescription
dataStream = response.GetResponseStream()
reader = New StreamReader(dataStream)
responseFromServer = reader.ReadToEnd()
Dim TimeSpent As System.TimeSpan
TimeSpent = Now.Subtract(TimerStart)
BetBotMainForm.oddschanging.Add("DL TIME: " + TimeSpent.TotalSeconds.ToString)
Catch ex As Exception
MsgBox("CreateRequest Error" & ex.Message)
End Try
Return responseFromServer '~~> Function Output
reader.Close()
dataStream.Close()
response.Close()
End Function
Is there a way to speed things up?

Thanks for your help!


Comment