-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zyan with Windows and Mono on Linux Raspberry #2
Comments
Hello Jens! Thanks a lot for your detailed description! 👍
Never seen this error in such situation. The error usually means (surprise!) that we have no registered channel of the given type, so the error's not gonna fix by itself. But in your case it magically goes away on the second call... That's unusual. Ok, let's try to reproduce it under the debugger. What version of Mono are you using? Does it behave the same on the latest version of Mono? On Windows version of Mono? Can you post a small console program that demonstrates this behavior? You can use this gist as a starting point for your sample (async/await stuff isn't relevant here and can be stripped away to make it simpler). Regards, Alexey |
BTW, do you use encryption? I saw such delays when running encrypted connections on a very low-end CPUs (RSA key generation is computation-intensitive, I think). Try disabling the encryption, perhaps it'll speed things up. |
Hello Alexey, thank you for your help. I did not turn on encryption explicit. Is it encrypted by default? How can I turn it off? Environment is:
all programs (dispatcher and agents) using this code: using System;
using System.Net;
using System.Reflection;
using Anytime.Agent.Model;
using Anytime.Remoting.Contract;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
namespace Anytime.Agent
{
class MainClass
{
private static ZyanComponentHost Host { get; set; }
private static AgentConfig settings;
private static DateTime StartTime = DateTime.Now;
// Haupteinstiegspunkt...
public static void Main(string[] args)
{
bool done = false;
try
{
string hostname = Dns.GetHostName().ToUpper() ?? "localhost";
// Host registrieren...
var protocol = new TcpDuplexServerProtocolSetup(8012);
Host = new ZyanComponentHost("test-service", protocol);
Host.RegisterComponent<IAgent, AgentService>();
// Warten bis Ende per ESC Taste gewünscht wird...
Console.WriteLine();
Console.WriteLine("Press ESC to stop the agent, BACKSPACE to simulate booking request...");
do
{
switch (Console.ReadKey(true).Key)
{
case ConsoleKey.Escape:
done = true;
break;
case ConsoleKey.Backspace:
SendBookingData();
break;
default:
break;
}
Console.Write("Incoming: {0} | Outgoing: {1} | Success: {2} | Error: {3} | Fatal: {4}\r",
CountI, CountO, CountS, CountE, CountF);
} while (!done);
}
catch (Exception e)
{
Console.WriteLine("Error...Reason: {0}", e.Message);
}
}
// Sende Buchungsdaten an den Dispatcher...
private static void SendBookingData()
{
string host = "192.168.22.192";
int dispatcherPort = 8012;
string dispatcherService = "test-agent1";
var protocol = new TcpDuplexClientProtocolSetup();
var url = protocol.FormatUrl(host, dispatcherPort, dispatcherService);
// Verbindung zum Host herstellen...
try
{
config = DispatcherConfig.GetConfiguration();
var protocol = new TcpDuplexClientProtocolSetup();
var url = protocol.FormatUrl(config.Host, config.Port, config.Service);
Console.WriteLine("(O:->) Try connecting to dispatcher on host {0}, port {1} with service {2}...",
config.Host, config.Port, config.Service);
using (var conn = new ZyanConnection(url, protocol))
{
var proxy = conn.CreateProxy<IDispatcher>();
proxy.SendTerminalData(Dns.GetHostName(), "004711", 0, 10100, DateTime.Now, false);
}
}
catch (Exception e)
{
Console.WriteLine("(O:->) Connection to dispatcher failed. Reason: {0}", e.Message);
}
}
// Dienstmethoden des Agent...
internal class AgentService : IAgent
{
// Einfache Anfrage, ob der Agent noch verfügbar ist, und wenn, seit wann...
public TimeSpan QueryAlive()
{
try
{
CountI++;
Console.WriteLine("(I:<-) Request received from dispatcher {0} - QueryAlive() ", DateTime.Now);
var ts = DateTime.Now - StartTime;
return ts;
}
catch (Exception e)
{
Console.WriteLine("(I:<-) Error in QueryAlive. Reason: {0}", e.Message);
throw new Exception(e.Message);
}
}
}
}
} |
I believe yes, it's on by default. To turn it off, specify new TcpDuplexServerProtocolSetup(8012) => new TcpDuplexServerProtocolSetup(8012, null, false);
new TcpDuplexClientProtocolSetup() => TcpDuplexClientProtocolSetup(false);
Have you tried this code on Mono for Windows? |
Don't hurry. I never tried mono on Windows. I'll implement it with turned of encryption and give you feedback. |
Hi Yallie, you saved my day, great!!! Turned off encryption an the times from the Raspberry are in milliseconds. So sending and receiving works very fast. For this solution its no problem with encryption disabled. Perhaps on a later stage in Raspberry Development I'll try to turn it on again. Calling the agents from my dispatcher, it's the same behavior. The first "mono" agent throws the error, but it's no problem. I'll catch this exception and make one retry so i get my results. If this is a little more stable, I'll make long term tests with dispatcher and agent. I'll tell you about. Small appendum: |
Hello Jens, glad to hear it helped with the encryption stuff!
Windows to Windows connections work just fine in lots of my projects, BTW, if by any chance you yourself use Vagrant and have a ready to use Regards, Alexey |
Ok, thank you. |
Hello Jens, I've installed Vagrant and set up Ubuntu 16.04.1 virtual box. I tried running the app on Windows and connecting from Windows machine. Here is my stripped down application code: using System;
using System.Linq;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
class Program
{
static void Main(string[] args)
{
if (!args.Any())
{
RunServer();
return;
}
RunClient(args.First());
}
public interface IAgent
{
void QueryAlive();
}
public class Agent : IAgent
{
public void QueryAlive()
{
Console.WriteLine("QueryAlive!");
}
}
public static void RunServer()
{
var proto = new TcpDuplexServerProtocolSetup(8012, null, false);
using (var host = new ZyanComponentHost("AgentService", proto))
{
host.RegisterComponent<IAgent, Agent>();
Console.WriteLine("Server started. Press Enter to quit");
Console.WriteLine("Hint: run 'test.exe tcpex://localhost:8012/AgentService' to connect.");
Console.ReadLine();
}
}
public static void RunClient(string url)
{
var proto = new TcpDuplexClientProtocolSetup(false);
using (var conn = new ZyanConnection(url, proto))
{
var proxy = conn.CreateProxy<IAgent>();
proxy.QueryAlive();
Console.WriteLine("Connected. Press Enter to quit");
Console.ReadLine();
}
}
} Please have a look, perhaps I am missing something important. Also, I'm not sure if Mono version is important here, but it could be great if you Please let me know how it goes. |
Hi Yallie, thanks a lot for your workout. I'll try it today. Just looked, my mono is 4.2.1 on Ubuntu VMWare Virtual machine and on Raspberry also. Regards Jens. |
Hello Jens,
UPD. Everything seems to be fine. |
Hi Yallie, just finished testing. Everthing work fine with your code in console application on windows and linux with ubuntu/mono. Event on Ubuntu with Mono Gtk#. Tested on Windows .NET 4.52 calling Mono Client on Virtual Machine with Ubuntu/Mono 4.6.2 and 4.2.1 (on Raspberry). Even first call does not produce any error. I discoverd, the namespace for the remoting interface must exactly match, else i get error the service ist not registerd. Then i tried my Windows/GUI part to call your code. This is part of my code in th windows service. Else I think I have the same code like you. ` public static async void AvailabilityCheck(int id)
Thank you a lot for your work. |
Hello Jens,
Please provide more details. Where do you run my test application as a server? On Ubuntu virtual box, right? PS. I know you have a workaround, but it still feels uneasy as we don't know the cause. |
Hi Yallie, sorry about confusing info. I run your application on windows as server, called by client from ubuntu/virtual machine and ubuntu/raspberry. Everything is ok. Running the application on Windows/WPF as server and client work fine. I run your application on ubuntu/virtual machine as server, called by client from ubuntu/raspberry and windows10/console-app. Everything is ok. What is not working is following: I'll try to make a small VS2015 project over the day to reproduce the error. Regards, Jens. |
Hi, First of all wish you a merry christmas and do no work so hard over the days. All the best for you. Made just a fresh solution with VS2015 attached. There are 4 projects within this solution:
You do not really need an IIS to run the WebApi, just change with command line to the project folder of the WebApi and run 'dotnet run' . This will start a webserver on port 5000 You can use Postman from google to post web request to the api, or just use any explorer to call the simple WebApi Method: 'localhost:5000/zyan/QueryAlive'. I coded some static ip-adresses in the dispatcher and agent. you must change them met your environment. So this is just the complete project running on my environment, hope it will work with you. Best regards, Jens. |
Hello Jens, Merry Christmas! Thanks a lot for your sample, will look into it. To be precise:
I don't see the error message about the channel being not registered in your screenhot. |
Hi Yallie, you are right very right. Now working at home I don't have the ability with several virtual machines. Working with my Mac with VM Ware Fusion having 1 Windows 10 and 1 Ubuntu Mono. But cannot start them together because of resources. So the part for the Ubuntu / Rapsberry was not compiled and running yet. I will do this tomorrow. So for your points:
So sorry about not yet finished complete. I think tomorrow or over tomorrow you' ll see the real result for the Ubuntu/Mono Server. All the best for you, Jens. |
Here is the outstanding result. Now my raspberry is up. Unfortunately it's the same result as in my large project. Also turned off IPv6, result is the same. Regards Jens. P.S.: The only great difference from the sample console application (which is working) to the new build solution is that the new solutions has already a zyan server connection open, when it calls the raspberry agents. But only on mono/linux workstations. Don't know why, It's beyond my horizon. |
Hello Jens,sorry for my late answer, got very sick lately. So you managed to reproduce the problem, that's awesome. I'll look into your sample once I get back home from hospital in a week or two. I believe the issue can be fixed as long as it's reproducible.Happy New Year!-- С уважением, Алексей25.12.2016, 02:55, "Jens Gühmann" <[email protected]>:Here is the outstanding result. Now my raspberry is up.
Unfortunately is is the same result as in my large project.
Also turned off IPv6, result is the same.
Regards Jens.
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
|
Hy Yallie, Get well first. We can talk in 2 or 3 weeks. My issue is not urgent. On friday i go for a one week vacation, back on 10th january. And yes i thing you'll fix it, when you see the project. Once again good improvement for you and a happy new year. Regards Jens. |
Hello Jens, Sorry for the long pause! I tried hard to compile your sample, but couldn't get it to work. A couple weeks ago I tried to update all .NET software stack, and installed the dotNetCore SDK v1.0.1-Preview 2.0.3. Still no use. Thanks, Alexey |
Hello Alexey,
no problem for pause, hope you are better now.
This is my VS2015 config.
[cid:d3ef838a-253c-4223-b5e4-0141dad8fe22]
Microsoft changes things in DotNet Core quite often now, it is actually at 1.1
I think your DotNet Core 1.0.1-Preview 2 SDK is already at Version 1.1.
It's a little bit strange with the version numbering.
https://www.heise.de/developer/artikel/NET-Core-1-1-installieren-birgt-einige-Herausforderungen-3491092.html
[http://www.heise.de/developer/imgs/06/2/0/3/6/8/7/9/netcore11Setup2-3b1181a65a619df1.jpeg]<https://www.heise.de/developer/artikel/NET-Core-1-1-installieren-birgt-einige-Herausforderungen-3491092.html>
.NET Core 1.1 installieren birgt einige Herausforderungen ...<https://www.heise.de/developer/artikel/NET-Core-1-1-installieren-birgt-einige-Herausforderungen-3491092.html>
www.heise.de
Vorgestern ist .NET Core in der Version 1.1 erschienen (siehe mein News-Beitrag dazu). Die Nutzung der neuen Version ist aber leider etwas erklärungsbedürftig, wie ...
Perhaps you omit my ASP.NET Core project and create a new project in the solution from template.
It is only a simple WebApi with one Controller and copy the source from my old in your new one.
Hope this helps.
Bye Jens
…________________________________
Von: Alexey Yakovlev <[email protected]>
Gesendet: Freitag, 10. Februar 2017 22:06
An: zyanfx/Zyan
Cc: Jens Gühmann; Author
Betreff: Re: [zyanfx/Zyan] Zyan with Windows and Mono on Linux Raspberry (#2)
Hello Jens,
Sorry for the long pause!
I tried hard to compile your sample, but couldn't get it to work.
When I open your HopeForSolution.sln, Visual Studio displays an error:
[image]<https://cloud.githubusercontent.com/assets/672878/22843912/ba3a3890-efec-11e6-9016-5492ecf745d6.png>
[https://cloud.githubusercontent.com/assets/672878/22843912/ba3a3890-efec-11e6-9016-5492ecf745d6.png]
A couple weeks ago I tried to update all .NET software stack,
I updated my Visual Studio 2015 to Update 3:
[image]<https://cloud.githubusercontent.com/assets/672878/22843949/e4355274-efec-11e6-986e-7060101f5d54.png>
[https://cloud.githubusercontent.com/assets/672878/22843949/e4355274-efec-11e6-986e-7060101f5d54.png]
and installed the dotNetCore SDK v1.0.1-Preview 2.0.3. Still no use.
What exact software versions do I need to compile the WebApi project?
Perhaps I better should recreate it from scratch? Please help me to build it.
Thanks, Alexey
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#2 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIjl41BaG4OnuItUHrRef0r_jhenYMYyks5rbNFegaJpZM4LQKaj>.
|
Hi Yallie,
here is a little bit about my Zyan project on Windows, Linux and Linux on Raspberry PI 2/3.
The project is about a Time Tracking Solution, Raspberry PI with Touch Panel 3,5" and RFID reader. Should act as time tracking terminal and optional as area access terminal via a relay or led to simulate access.
All the components are wired on a breadboard and are working fine. Raspberry IO are managed via Raspberry IO General Purpose assembly on NuGet.
The environment is as following:
I have a Windows Zyan Host (Dispatcher) running as service.
I have 4 Zyan Hosts called Agent, 1 on Windows, 1 on Linux Ubuntu with Mono and 2 on Linux Ubuntu with Mono on Raspberry PI 3b.
The Windows Dispatcher is the central program making requests to the clients (agents) and receives request from the clients (agents).
Windows Agent and Linux Agent on Ubuntu are only for testing/debugging purpose. The two Raspberry Linux Agents are the real time tracking and area access terminals.
Raspberry agents have MongoDB locally installed and save the actual time bookings in the database and send a time booking request to the dispatcher (windows service) if available. If not available, later the dispatcher tries to get the bookings from the agents.
Bidirectional Communication and it works.. (Windows <-> Linux/Mono, Windows <-> Raspberry/Mono, Linux/Mono <-> Raspberry/Mono)
But...I have some strange behavior:
Sending request from the dispatcher:
If a make a "QueryAlive" request to all my agents, the first Linux/Mono gets an error with the following message:
Cannot create channel sink to connect to URL /98b09d86_a7b0_4134_91fd_a73b5be56b4a/tuemzdslijppnf8agyjtj7li_3.rem. An appropriate channel has probably not been registered.
If I try it just after this call, every is fine. First call does not succeed.
Every agent has a method to send booking data to the dispatcher, this is the behavior:
This is my method to contact the agents/dispatcher...
using (var conn = new ZyanConnection(url, protocol))
{
var proxy = conn.CreateProxy();
var ts = proxy.QueryAlive();
}
Any idea about this behavior???
But it works with the workarounds.
Thanks, Jens.
The text was updated successfully, but these errors were encountered: