SignalGo/SignalGo-full-net

provide working samples and documentation

Closed this issue · 15 comments

Since yesterday I try to get the lib to work. In my client I created a ClientProvider and called Connect with the Server URL.

Buit what's next? When I call _service = _clientProvider.RegisterServerService<MyService>(_clientProvider); I get a System.MissingMethodException that constructor for MyService is not found.

In your demo this line is commented out 🤔

In your demo you create the service like this

var httpClient = new HttpClient();
_service = new MyService("URL:Port/SignalGo", httpClient);

but calling any generated function causes service not found exception, which I don't understand, because the VS extension connected to the service, fetched the data and generated the code 🤔 🤷‍♂️

Why do I need ClientProvider and calling Connect?

Please create a real documentation with all steps, currently the lib is unusable, because we have no idea how to use it correctly.

Ok, Lets fix your problems then I will document them.
ClientProvider is for duplex protocols (like WebSockets or signalgo duplex protocol) if you using HttpService over your service you don't need use ClientProvider.
[ServiceContract("Authentication", ServiceType.HttpService, InstanceType.SingleInstance)]

But if you using ServerService over your Service you need to Connect with ClientProvider. in Signalgo you can use both of protocols for your service.
example:

//for http calls
[ServiceContract("Authentication", ServiceType.HttpService, InstanceType.SingleInstance)]
//for duplex calls
[ServiceContract("Authentication", ServiceType.ServerService, InstanceType.SingleInstance)]
 public class AuthenticationService
 {
 }

if you used HttpServices over your server services,you can call them like:

var service = new MyTestServices.HttpServices.HelloWorldService("http://localhost:9674");
var result = service.Login("test","test");

HttpServices will generate with code generator in "MyServiceNameSpaces.HttpServices" but duplex services will generate with code generator in "MyServiceNameSpaces.ServerServices".
so you dont need register http services,you can instance them directly and call methods but for server services (duplex) you need register them in ClientProvider then Connect then call methods.

ok, those important information needs to be documented. I'll play with it a bit more.

ok, I can now call sync methods fine with the as stream/Duplex connection with webspocket enabled, but real async methods throw System.Threading.Tasks.TaskCanceledException

System.Threading.Tasks.TaskCanceledException: Eine Aufgabe wurde abgebrochen.
   bei SignalGo.Client.ClientManager.ConnectorExtensions.<SendDataAsync>d__15.MoveNext() in D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\ClientManager\ConnectorExtensions.cs:Zeile 263.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei SignalGo.Client.ClientManager.ConnectorExtensions.<SendDataAsync>d__6`1.MoveNext() in D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\ClientManager\ConnectorExtensions.cs:Zeile 73.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei Foo.SignalGoProvider.<LogOnAsync>d__108.MoveNext()

Can you show me your example code? Thank You

I can't share this huge application.

I also get when I call a sync method that return complex class. Simple types like string, bool work, but large fails for both.

System.AggregateException: Mindestens ein Fehler ist aufgetreten. ---> System.Threading.Tasks.TaskCanceledException: Eine Aufgabe wurde abgebrochen.
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei SignalGo.Client.ClientManager.ConnectorExtensions.SendData(ConnectorBase connector, MethodCallInfo callInfo) in D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\ClientManager\ConnectorExtensions.cs:Zeile 315.
   bei SignalGo.Client.ClientManager.ConnectorExtensions.SendData(ConnectorBase connector, String serviceName, String methodName, ParameterInfo[] args) in D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\ClientManager\ConnectorExtensions.cs:Zeile 198.
   bei SignalGo.Client.ClientManager.ConnectorExtensions.SendDataSync[T](ConnectorBase connector, String serviceName, String methodName, ParameterInfo[] args) in D:\SignalGo\Github\SignalGo-full-net\SignalGo.Client\ClientManager\ConnectorExtensions.cs:Zeile 91.

THis is confusing because I don't call async, but in code I see you mix sync/async again:

#if (NET40 || NET35)
internal void SendDataSync(MethodCallInfo callback)
#else
internal async void SendDataSync(MethodCallInfo callback)

I call method that should be sync, but internally it is async

TaskCanceledException happens when your connections disconnect, its happens when:
1.You make multiple ClientProvider in client side
2.Use wrong way for call server method

I don't want your huge application, just:

1.Server method (not body of method) I need your result type and parameters
2.ClientProvider connection and registeration services and everything about signalgo you registered
3.Client method calling code

no more codes.

how can I reconnect if connection is lost? I (think that I) use the correct one now, client provider and ServerServices and the code is generated from your extension.

I'll wait now one week for a documentation (not undocumented samples without explaination what each line means) or stop trying to use it.

please read the document here i update it however for auto reconnection:

https://github.com/SignalGo/SignalGo-full-net/wiki/Client-Providers-(Client-Side-Example)

if you have Telegram application you can call me online and ask me everything I will answer your questions.
my Telegram user:
@Ali_Visual_Studio

I don't use Telegram.

In output I see a lot of "Exception thrown: 'System.Exception' in SignalGo.Shared.dll" entries, so I told VS to stop and here I see this:

System.Exception: 'your count request is 512 but i read 544 from stream in websocket!'

SignalGo.Shared.dll!SignalGo.Shared.IO.WebSocketStream.ReadAsync(byte[] buffer, int offset, int count) Line 197	C#
[Resuming Async Method]	
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(object stateMachine) Line 1090	C#

So this is the underlaying issue why it fails, not a connection problem.

When I continue debugging, I later get

System.Exception: 'read zero buffer! client disconnected'

here the client gets disconnected

To be able to step into your code without compiling it myself, activate Source Link and upload the snupkg symbols file to NuGet, too.

Based on a part of the error message

from stream in websocket!

I found my cause, I set ProtocolType to WebSocket, using default SignalGoDuplex works.

Again, this only happens because of missing documentation. You have not documented when to set it and when use which Type. Learn with samples is NO proper documentation.

I think there is some bugs I cannot find it when I have no example from you.I don't need full example just need Client providers and how you call the services.and mybe you are calling stream service from duplex services or something else.
about documentation:
I will full document signalgo after signalgo 6 released becase we have more refactor and breaking changes in this version . so we need finish version6 and document it again.

ok, so I'll stop playing with v5 and wait for v6. Here also please enable Source link.

don't close it until you have a working documentation.