Closed dakriege closed 5 years ago
That's somehow weird. I see no reason why it should behave different just because it's called by a web service. How long is the timeout it hits? Some request (especially the first few after starting the car) can take quite a while to complete.
I changed the debug logger to save to a flat file so I could watch all of the events.
I created a C# and VB .net .asmx page. I’m using VB so I thought maybe it had an issue with the DLL’s.
HTML5 Page Ajax Call to the Web Service -> Web Service does an await call to .RequestDataAsync(
It parses the Command, Queues it, Writes it and gets a reply.
When RequestDataAsync gets the return from the await result.WiathHandle.WaitAsync I added a log message
This is the point where it times out. 2-3 Minutes.
Eventually It logs the data returned message but never returns back to the original caller, .Net times out on the Ajax call.
I added a Task.Run() to the RequestDataAsync(pid).
I ended up creating a routine that subscribes to the data that I need and then use a timer to fire the request data triggers.
The data received event handlers update public variables for the subscribed data to be read
The ajax call now asks for the data values instead of the async calls to get values.
BTW – If I run this for an extended period of time I’ve had an exception occur that crashes IIS.
The _serialPort.Write(data,0,data.length) triggers an exception on a Write data timeout.
I added a try / catch to see if it still crashes
Would you know how to do the code below in VB ?
This is code I have working
public int pubSubscribeRpm()
{
try
{
if (OBD2Dev == null)
{
return -2;
}
//Can’t figure out the VB equivalent to specify the event handler
OBD2Dev.SubscribeDataReceived<EngineRPM>((sender, data) => updateRpm(data.Data));
return 1;
}
catch (Exception ex)
{
LogMsg("subscribe Rpm RT Err: " + ex.Message);
return -1;
}
}
public void updateRpm(EngineRPM dataUpdate)
{
curRPM = dataUpdate.Rpm.ToString();
}
This is the vb code
Public Sub subscribeToRpm()
‘This line reports a syntax error on the updateRpm((Of EngineRPM)))
OBD2Dev.SubscribeDataReceived(Of EngineRPM)(AddressOf updateRpm((Of EngineRPM)))
End Sub
Private Sub updateRpm(dataRecd As EngineRPM)
CurRPM = dataRecd.Rpm.ToString()
End Sub
Dave
From: DarthAffe [mailto:notifications@github.com] Sent: Tuesday, August 20, 2019 4:37 PM To: DarthAffe/OBD.NET OBD.NET@noreply.github.com Cc: dakriege dakrieger@ameritech.net; Author author@noreply.github.com Subject: Re: [DarthAffe/OBD.NET] WebService Issue (#12)
That's somehow weird. I see no reason why it should behave different just because it's called by a web service. How long is the timeout it hits? Some request (especially the first few after starting the car) can take quite a while to complete.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DarthAffe/OBD.NET/issues/12?email_source=notifications&email_token=AGDU3TB6GHAFMP3XCLPZH73QFRIYBA5CNFSM4INB5DIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4XSTQA#issuecomment-523184576 , or mute the thread https://github.com/notifications/unsubscribe-auth/AGDU3THMBYI4CYO5NUFFFJDQFRIYBANCNFSM4INB5DIA . https://github.com/notifications/beacon/AGDU3TCGD5RJ6XXQUXNAXATQFRIYBA5CNFSM4INB5DIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4XSTQA.gif
Virus-free. http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient www.avg.com
Converted the C# SubscribedDataReceived to the VB lambda equivalent.
Everything is working.
No need to research why the Async calls fail.
The triggered method is going to be more efficient delivering data to my HTML page.
Dave
From: DarthAffe [mailto:notifications@github.com] Sent: Tuesday, August 20, 2019 4:37 PM To: DarthAffe/OBD.NET OBD.NET@noreply.github.com Cc: dakriege dakrieger@ameritech.net; Author author@noreply.github.com Subject: Re: [DarthAffe/OBD.NET] WebService Issue (#12)
That's somehow weird. I see no reason why it should behave different just because it's called by a web service. How long is the timeout it hits? Some request (especially the first few after starting the car) can take quite a while to complete.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DarthAffe/OBD.NET/issues/12?email_source=notifications&email_token=AGDU3TB6GHAFMP3XCLPZH73QFRIYBA5CNFSM4INB5DIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4XSTQA#issuecomment-523184576 , or mute the thread https://github.com/notifications/unsubscribe-auth/AGDU3THMBYI4CYO5NUFFFJDQFRIYBANCNFSM4INB5DIA . https://github.com/notifications/beacon/AGDU3TCGD5RJ6XXQUXNAXATQFRIYBA5CNFSM4INB5DIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4XSTQA.gif
Virus-free. http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient www.avg.com
I created a simple .net WebService API to retrieve PID values to display on a page.
I confirmed that my OBD2 module is working via the example Client.
When I make a call to the requestDataAsync<> function it sends the data to the module and receives the hex response. At that point it appears to hang / timeout. Eventually the call completes but by that time the web service call has timed out and returns an error to the Page.
The web service method is using await when it calls the requestDataAsync function.
Any ideas?