StopTransaction => Exception: Error converting value {null} to type 'System.Int32'
Closed this issue · 1 comments
JeremyMahieu commented
We had this exception in the logging. Not sure what went wrong exactly but the EV charger seems to accept the charing session, then immediatly (about 450ms later) stopped the transaction and while stopping this was logged.
2023-08-31T11:12:08.470119992Z fail: OCPP.Core.Server.ControllerOCPP16[0]
2023-08-31T11:12:08.470156990Z StopTransaction => Exception: Error converting value {null} to type 'System.Int32'. Path 'transactionId', line 1, position 100.
2023-08-31T11:12:08.470162285Z Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path 'transactionId', line 1, position 100.
2023-08-31T11:12:08.470166293Z ---> System.InvalidCastException: Null object cannot be converted to a value type.
2023-08-31T11:12:08.470170019Z at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
2023-08-31T11:12:08.470173731Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
2023-08-31T11:12:08.470177771Z --- End of inner exception stack trace ---
2023-08-31T11:12:08.470189007Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
2023-08-31T11:12:08.470193655Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
2023-08-31T11:12:08.470209951Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
2023-08-31T11:12:08.470219734Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
2023-08-31T11:12:08.470292399Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
2023-08-31T11:12:08.470322085Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
2023-08-31T11:12:08.470367614Z at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
2023-08-31T11:12:08.470373702Z at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
2023-08-31T11:12:08.470377432Z at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
2023-08-31T11:12:08.470386265Z at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
2023-08-31T11:12:08.470390377Z at OCPP.Core.Server.ControllerOCPP16.HandleStopTransaction(OCPPMessage msgIn, OCPPMessage msgOut) in /src/OCPP.Core.Server/ControllerOCPP16.StopTransaction.cs:line 41
JeremyMahieu commented
Upon further inspection it seems the EV Charger sent a stop transaction with an empty transaction id, and this is required by the protocol. So can't fault the OCPP server.
This is the logging from the EV Charger's perspective. It seems an empty transactionId was sent. So this would probably be a
2023-08-31 11:11:49,933;INFO ;m.websocket : [1002] Communication -out -> [2, "10022f4a-4263-4300-a0f1-32088c7a47cb", "StopTransaction", {"idTag": "REDACTED", "meterStop": 1146195, "timestamp": "2023-08-31T11:11:48Z", "transactionId": "", "reason": "Local"}]
2023-08-31 11:11:50,022;INFO ;m.websocket : [1023] Communication -in -> [4,"10022f4a-4263-4300-a0f1-32088c7a47cb","FormationViolation","",{}]
https://www.oasis-open.org/committees/download.php/58944/ocpp-1.6.pdf