[en] File Transfer with Zyan (solved)

Topics: Technical Support
Dec 2, 2013 at 5:19 PM
Edited Dec 2, 2013 at 5:20 PM
hey,

I will try to implement a small file-Transfer function for a selfupdateing application. I read https://zyan.codeplex.com/SourceControl/changeset/view/29230#428499 but i´m not able to do work.

Here my Client side code:
_UpdateProxy = ConnectClient.Connection.CreateProxy(Of IUpdateComponent)()

  ' Erzeugt die lokale Datei
                    _localStream = File.Create(ApplicationSettings.EXE_FOLDER_NAME & "\" & ServerFile.Name)

                    ' Verbindung zur Remote-Datei
                    _remoteStream = _UpdateProxy.DownloadFile(ServerFile.Name)

                    ' Übertragen
                    _remoteStream.CopyTo(_localStream)

                    _remoteStream.Close()
                    _localStream.Close()
Here my Server-Side code
  Public Function DownloadFile(FileName As String) As System.IO.Stream Implements IUpdateComponent.DownloadFile

        Dim _localStream As Stream

        ' Öffnet die lokale Datei um sie zu übertragen
        _localStream = File.OpenRead(ServerInstanceData.DirectoryWithClientFiles & "\" & FileName)

        Return _localStream

    End Function
If I try to download the file, following error come up: "This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server" or in german "Der Remoteproxy hat keine Channelsenke, d. h., der Server besitzt keine registrierten Serverchannel oder die Anwendung hat keinen passenden Clientchannel, um mit dem Server zu kommunizieren"

did some know what I have Forget?

Thanks for the help
Coordinator
Dec 3, 2013 at 11:07 AM
Hi!

I don't see any errors in your code. What channel do you use?
I've written my own sample program similar to yours, and it work without errors:
var serverUrl = "tcp://localhost:8194/SampleStreamServer";
using (var zyanConnection = new ZyanConnection(serverUrl))
{
    var proxy = zyanConnection.CreateProxy<IStreamService>();
    var input = proxy.Download(inputName); // remote stream
    var output = File.Create(outputName); // local stream

    input.CopyTo(output);
    input.Close();
    output.Close();
}
On its first run my sample program starts the server:
Server is ready. Press ENTER to stop.

Run the program again to download the file using streams.
On the second run it starts the client which connects to the server and downloads the file using FileStream:
Connecting to tcp://localhost:8194/SampleStreamServer...

Downloading remote file: D:\Experiments\ZyanBugs\MyKey0815\streams.exe
Download complete: D:\Experiments\ZyanBugs\MyKey0815\streams.exe.635216799121817157.dat.
Press ENTER to quit.
The complete code for this program is located here: https://gist.github.com/yallie/7767323
Please compile it using C# and tell me if it works on your machine.
Dec 3, 2013 at 2:00 PM
Edited Dec 3, 2013 at 2:03 PM
Thanks,

I have compile your code - it works fine.

Then I Change to TcpDuplex and the same error came up
static void RunServer()
    {

        var protocol = new TcpDuplexServerProtocolSetup(8194,new NullAuthenticationProvider(), true);
        using (var zyanHost = new ZyanComponentHost("SampleStreamServer", protocol))
        {
            zyanHost.RegisterComponent<IStreamService, StreamService>();

            Console.WriteLine("Server is ready. Press ENTER to stop.");
            Console.WriteLine();
            Console.WriteLine("Run the program again to download the file using streams.");
            Console.ReadLine();
        }
    }

 static void RunClient()
    {
        var serverUrl = "tcpex://localhost:8194/SampleStreamServer";
        Console.WriteLine("Connecting to {0}...", serverUrl);
        Console.WriteLine();

        using (var zyanConnection = new ZyanConnection(serverUrl))
        {
            var inputName = typeof(Program).Assembly.Location;
            var outputName = inputName + "." + DateTime.Now.Ticks + ".dat";
            Console.WriteLine("Downloading remote file: {0}", inputName);

            var proxy = zyanConnection.CreateProxy<IStreamService>();
            var input = proxy.Download(inputName);
            var output = File.Create(outputName);

            // copy data
            input.CopyTo(output);

            // close streams
            input.Close();
            output.Close();

            Console.WriteLine("Download complete: {0}.", outputName);
            Console.WriteLine("Press ENTER to quit.");
            Console.ReadLine();
        }
The file will created - but no data will copied. The file have a length of 0
Coordinator
Dec 3, 2013 at 2:22 PM
Ah, I see.
It must be a bug in TcpExChannel. I'll create an issue for it.

I'm afraid you'll have to use standard TCP channel until the bug is fixed.
Thanks for reporting!
Coordinator
Dec 3, 2013 at 2:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 3, 2013 at 2:25 PM
yallie wrote:
Ah, I see.
It must be a bug in TcpExChannel. I'll create an issue for it.

I'm afraid you'll have to use standard TCP channel until the bug is fixed.
Thanks for reporting!
OK - I cannot use Standard TCP, but is no Problem in the meantime. I will wait until you fix the bug. Then I can release the "Self-Updating-Application"- Feature ;-)
Coordinator
Dec 4, 2013 at 10:05 AM
MyKey0815 wrote:
 
OK - I cannot use Standard TCP
 
Why not?

You can easily create a separate ZyanComponentHost for the update service and use standard TCP channel for it.
It will probably need another authentication/authorization scheme anyway (for example, no authentication, so that anyone can update the software).
Your main service will still use duplex tcp, while the update service will be simplex tcp-based.
Dec 4, 2013 at 10:13 AM
yallie wrote:
You can easily create a separate ZyanComponentHost for the update service and use standard TCP channel for it.
It will probably need another authentication/authorization scheme anyway (for example, no authentication, so that anyone can update the software).
Your main service will still use duplex tcp, while the update service will be simplex tcp-based.
OK - that is a nice workaround. Do you think, that you Need a Long time to resolve the Problem? If you can fix it in few days then I will wait on the fix. But if you think you Need much weeks or months then I will implement the Workaround
Coordinator
Dec 4, 2013 at 11:21 AM
Unfortunately, I am currently very busy (the end of a year is always a hot time), so I can't promise to handle it in a few days.
I don't see an easy way to fix the bug, so it might need quite a bit of time to research.
Coordinator
Dec 16, 2013 at 7:13 PM
The bug is fixed, please download the latest changeset.
Marked as answer by yallie on 12/16/2013 at 11:13 AM
Dec 16, 2013 at 9:30 PM
Thank you very very much.

After I recompile your source and the activation of the update-Routine now the Transfer of files in tcpex is working fine.

I wish you a fine day

PS: Thank you for the fast Response and Fixing the bug. I came to the right time - In 2 Days we will relase a new Version of our application
Coordinator
Dec 16, 2013 at 9:54 PM
That's great! Glad to help you and thanks for reporting this bug :)

Out of curiosity: what your project is about?
Can you disclose but a few words about it here — https://zyan.codeplex.com/discussions/337472
It would be very appreciated.

Kind regards, Alex