1

Is there a way to log detailed ftp traffic from microsoft hosted agent? In my case, when running ui tests in release pipeline, screenshoots are uploaded to ftp server. It worked fine for few weeks unitl yesterday when I started getting following errors:

enter image description here

There was no change on the ftp server side and in c# code used for uploading ftp files. Uploading files still works fine when i run tests locally and this issue happens only when they are run from pipeline, so I thought about comparing network traffic, looking for some clues.

Adam Stawarek
  • 321
  • 4
  • 9
  • Can't you add some logging to your tests? Log the ftp address and capture exception message etc. – tubakaya Nov 23 '20 at 10:41
  • 1
    if it's an FTP upload then why do you want HTTP logs? – ADyson Nov 23 '20 at 10:51
  • @ADyson yes, my mistake I need ftp logs. I've updated description – Adam Stawarek Nov 23 '20 at 11:08
  • @tubakaya, i have logs but they contain company data so I can't attach them to this post/question. The ftp address is fine, as well as credentials, the only exception is the one from screenshoot in the description – Adam Stawarek Nov 23 '20 at 11:15
  • The exception is about the protocol, so I would check whether anything changed with settings. See this post https://stackoverflow.com/questions/26278782/the-underlying-connection-was-closed-the-server-committed-a-protocol-violation. There is also a post that suggests not to use the system.net.ftpwebrequest and instead to use alternatives, see here: https://learn.microsoft.com/en-us/dotnet/api/system.net.ftpwebrequest?view=net-5.0 – tubakaya Nov 23 '20 at 11:52
  • Hi @AdamStawarek. You could refer to the method in the answer and collect the ftp traffic log. On the other hand, since it could work on your local machine, you could also use the [Self-Hosted Agent](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops&tabs=browser#install) and check if it could work. – Kevin Lu-MSFT Nov 24 '20 at 02:36
  • @KevinLu-MSFT sorry for late response. In next week I will get funds in aws to create virtual machine, which i plan to use also as pipeline agent instead of default one hosted by Microsoft, so my orginal problem should resolve itself. Still your anwser is great, and probably will be of great help to me or others in the future. Thanks :) – Adam Stawarek Nov 28 '20 at 17:28

1 Answers1

1

Is there a way to log detailed ftp traffic from microsoft hosted agent?

You could try to use the network tracing to collect the Ftp traffic log.

You could add the configuration in the config file (e.g. web.config , app.config).

For example: To collect the FTPWebRequest and FtpWebResponse information, you could use system.net.

<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.Net" tracemode="protocolonly" maxdatasize="1024">
        <listeners>
          <add name="System.Net"/>
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="System.Net" value="Information"/>
    </switches>
    <sharedListeners>
      <add name="System.Net"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="network.log"
      />
    </sharedListeners>
    <trace autoflush="true"/>
  </system.diagnostics>
</configuration>

Then it will create a network.log file.

Since you are using the Microsoft-Hosted agent, you could determine the file location and use the Publish Build Artifacts task to upload the file as build artifacts.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28