API Support Forum
OEC API > API Support > Getting Error if application has no internet access
Author Topic: Getting Error if application has no internet access
(3 messages, Page 1 of 1)
Moderators: VPfau
BGoyal9136
Posts: 27
Joined: Sep 21, 2017


Posted: Jul 01, 2020 @ 07:51 AM             Msg. 1 of 3
Hi Support,

I am getting error from GF api when application doesn't has internet access.
Below are the stack trace for your reference. could you Please help me out to solve this :

Exception Info: System.InvalidOperationException
at GF.Api.Impl.Connection.Machine.States.ClosedConnectionState.OnDisconnect(GF.Api.Impl.Connection.Machine.DisconnectionContext)
at GF.Api.Impl.Connection.Machine.ConnectionStateMachine.Transition(System.Func`1)
at GF.EnumerableTExtensions.ForEach[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral,


Thanks
ETrifonov
Posts: 60
Joined: Feb 09, 2015


Posted: Jul 01, 2020 @ 12:11 PM             Msg. 2 of 3
Hello,

From just stack trace it is unclear what cause that.
Can you please provide more details, like connect/disconnect code.
Are you calling connect method on a GF API thread?

Thank you.
Evgeny
LBratovich4305
Posts: 8
Joined: Jul 15, 2019


Posted: Jul 02, 2020 @ 03:41 AM             Msg. 3 of 3
I had the same problem and thought it was a bug in my code.

I solved it using a simple check
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())



I get this error if I try to connect with no network: -----------------------------

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
at GF.Api.Impl.Connection.CurrentUserStore.Clear(ServerType serverType)
at GF.Api.Impl.Connection.Machine.States.ClosedConnectionState.OnEntry()
at GF.Api.Impl.Connection.Machine.ConnectionStateMachine.Transition(Func`1 getNewState)
at GF.Api.Impl.Connection.Machine.ConnectionStateMachine.OnDisconnect(DisconnectionContext context)
at GF.Api.Impl.Connection.Machine.ConnectionStateMachine.ConnectionDisconnected(Exception exception)
at System.Action`1.Invoke(T obj)
at GF.Api.Impl.Connection.ApiConnection`2.d__27.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GF.Api.Impl.Connection.Machine.States.ConnectingConnectionState.d__21.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.c.b__6_1(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

------------------------------------------------