This article presents ways to work around Internet connection errors that I use in practice.

In my case, the problem was solved by editing the file C:\WINDOWS\system32\drivers\etc\hosts "192.168.0.1 site domain name" on the client or server - where the routine task runs. After this, the built-in 1C Internet connections started working:

ExchangeFileDirectory = "D:\temp\"; ResponseFileName = ExchangeFileDirectory + "cards.xml"; Headers = "discount.php"; Proxy = Undefined; Try Proxy = New InternetProxy; ProxyK.Set("http", ProxyK.Server("http"), ProxyK.Port("http")); Exception EndTry; ProxyC.User = "**********"; Proxy.Password = "************"; Connect = New HTTPConnection("site domain name", Proxy); Attempt Connect.Get(Headers,ResponseFileName); Connect = Undefined; Exception Error = ErrorDescription(); Ф = New TextDocument; F.AddRow(Error); F.Write(ResponseFileName); Ф = ""; EndAttempt;

Editing etc\hosts also helped, after which the connection from the publication Sending an HTTP string with response processing started working

Trying XMLHttp = GetCOMObject("", "Microsoft.XMLHTTP"); Exception Error = ErrorDescription(); Ф = New TextDocument; F.AddRow(Error); F.Write("D:\temp\cards21.txt"); Ф = ""; Return; EndAttempt; Attempt XMLHttp.Open("GET", "http://sitedomainname/discount.php", False); Exception Error = ErrorDescription(); Ф = New TextDocument; F.AddRow(Error); F.Write("D:\temp\cards22.txt"); Ф = ""; Return; EndAttempt; XMLHttp.Send(); If XMLHttp.Status = 200 Then Str = ""; TryStr = XMLHttp.ResponseText; Exception Page = ErrorDescription(); EndAttempt; Ф = New TextDocument; F.AddRow(Str); F.Write("D:\temp\cards23.txt"); Ф = ""; Otherwise F = New TextDocument; F.AddRow(XMLHttp.Status); F.Write("D:\temp\cards24.txt"); Ф = ""; endIf;

The connection works fine through the dialmail component, but we couldn’t get it to work:

//If Load External Component(IB Catalog() + "DialMail.dll") = 0 Then // Report("Failed to load component DialMail.dll!"); //Return Status(0); // Return; //EndIf; //Attempt // FTP = CreateObject("AddIn.FTP"); // FTP.LogFileName = "c:\dialmail_ftp.log"; // FTP.VestiLogFile = 1; // FTP.NewTechnicalLogFile = 1; //Exception // Report("Could not create an object from the DialMail.dll component!"); //Return Status(0); // Return; //EndAttempt; //FTP.ProxyUserName = ProxyUserName; //FTP.PasswordProxy = PasswordProxy; //FTP.HostProxy = HostProxy; //FTP.PortProxy = PortProxy; //// If FTP.UseProxy = 0 then //// all the above parameters are not taken into account //FTP.UseProxy = 2; //FTP.UseSSL = 0; //FTP.NewRFC = 0; //FTP.BinaryMode = 0; //FTP.TimeBeforeBreak = 1000000; // Timeout //If FTP.Connect(FTPServer, // FTPPort, // FTPUser, // FTPPassword, 0) = 0 Then // Warning("Could not connect to the FTP server"); //Else //Connected = 1; //EndIf; //Notify(FTP.StringObjectVersion); //TechFTPDirectory = FTP.CurrentDirectory();

03/28/13 13:44:01.500 FTP: Connect to the socket
03/28/13 13:44:01.515 FTP: Connected to the socket successfully
03/28/13 13:44:01.671 FTP 03/28/13 13:44:01.671 FTP --> USER 931013677
03/28/13 13:44:01.687 FTP 03/28/13 13:44:01.687 FTP --> PASS *****
03/28/13 13:44:01.703 FTP 03/28/13 13:44:01.703 FTP --> TYPE I
03/28/13 13:44:01.718 FTP 03/28/13 13:44:01.718 FTP --> STRU F
03/28/13 13:44:01.734 FTP 03/28/13 13:44:01.734 FTP --> REST 0
03/28/13 13:44:01.734 FTP 03/28/13 13:44:01.750 FTP --> REST 1
03/28/13 13:44:01.750 FTP 03/28/13 13:44:01.765 FTP --> REST 0
03/28/13 13:44:01.765 FTP 03/28/13 13:44:01.781 FTP --> PWD
03/28/13 13:44:01.781 FTP 03/28/13 13:44:02.968 FTP --> PWD
03/28/13 13:44:02.984 FTP 03/28/13 13:44:02.984 FTP --> PASV
03/28/13 13:44:03.000 FTP03/28/13 13:44:03.000 FTP --> LIST

When I try to upload a file to the server, I get socket errors 10054

Socket Error #10054 Connection reset by peer

There is little written about this dialmail error on the Internet, mainly that it occurs, without a solution. On Gilev’s website it is written about this error that it occurs in the platform: http://www.gilev.ru/10054/

My way:

  1. winscp downloads the file (works even without editing etc\hosts)
  2. The http link jerks with curl (although curl does not work without editing etc\hosts)

Here is a list of the main fundamental issues when solving the practical problem of using an Internet connection using an external client, which turned out to be important to pay attention to...

I learned about curl from the specialists at pradata.com
curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of others

The publication Uploading files to SFTP helped about winscp

DNS address decoding may be disabled on the server (as in my case), so instead of the domain name of the site, use a digital IP address.

The text of the procedure that actually works for me (I overwrite the file in a temporary local directory and upload it to the server):
Procedure Report(TabDoc, DataCon, DateStart) Export F = New TextDocument; F.AddLine("BarCode;Period;Purchase Amount"); File="d:\temp\discount.txt"; F.Write(File); // http://programna1c.narod.ru/docs/WSH/1C_WSH_WshShell.html //Run(,) Executes the command. The main advantage is the presence of waiting for the completion of the executed command. //Parameters: // - the command to be executed. It is specified in DOS format and does not support long names. // - a number indicating the option for displaying the window of the application being launched. Not required. Possible values: //0 - Hides a window and activates another; //1 - Activates and displays the window. If a window is minimized or maximized, the system restores it to its original size and position. Used when opening the program window for the first time. //2 - Activates the window in minimized mode. //3 - Activates the window and expands it to full screen. //4 - Shows the window in its new size and position. The current window remains active. //5 - Activates the window and shows it in the current size. //6 - Minimizes the window and activates the following on the taskbar. //7 - Shows the window as minimized. The active window remains active. //8 - Shows the window in its current state. The active window remains active. //9 - Activates and displays the window. If a window is minimized or maximized, the system restores it to its original size and position. Used to restore a minimized window. //10 - shows the window in the same state as the calling program window. // - flag for waiting for process completion. Possible values: 0 - do not wait for the command to complete execution; -1 - wait for the command to complete execution. Not required. Default is 0. //Note: You can run both the application and any command (similar to Start->Run). //Example: //WshShell = New COMObject("WScript.Shell"); //WshShell.Run("notepad",7,-1); WshShell = New COMObject("wscript.Shell"); //Contents of the ap.ini file //open ftp://******:********@****************** // rm discount.txt //option transfer ascii //put D:\temp\discount.txt //close //exit CommandLine = "" ReturnValue = WshShell.Run(CommandLine, 1); WshShell = Undefined; End of Procedure

Here is what applies to the external ftp client:

Command to run the script:

D:\temp\WinSCP.com /script=D:\temp\ap.ini

Script text:

open ftp://**************:**************@*************** ****** // after the dog the IP address, not the domain name
option transfer ascii
rm discount.txt
put D:\temp\discount.txt
close
exit

The result of running this script:

D:\temp>D:\temp\WinSCP.com /script=D:\temp\ap.ini
Connecting to ***************** ...
Connected with *********************. Waiting for welcome message...
Connected
Starting the session...
Reading remote directory...
Session started.
Active session: ************@**********************
transfer ascii
discount.txt
D:\temp\discount.txt | 42 KiB | 39.1 KiB/s | ascii | 100%
Session "****************@***************" closed.
No session.

I solved my problems using the WinSCP.com client, thanks to the publication Uploading files to SFTP

The first thing you need to do is install the free WinSCP program, you can download it, and there is also all the necessary literature on using this program.

After you have installed the program, you need to add a session, everything is simple, you register the host, port, login and password for the server.

I also advise you to keep logs of this program, so that you can then at any time see why data exchange did not occur or check the log for the success or failure of file synchronization. In order for you to create a log, you need to go to the “Logging” tab, check the “Record file” checkbox and select the path, I advise you to make the file name this way! S!Y!M!D.txt, this means that a new one will be created every day a log file with this name S - session name, Y - year, M - month, D - day, that is, it will be much more convenient for you to read data from the logs later.

Now let's proceed directly to programming in 1c and for this we only need to know the basic WinSCP commands, the entire list of which can be viewed on the program website. And I will give you only those commands that I used and which, in my opinion, are enough for 1c to successfully exchange data with sFTP or FTPs servers. I will also write what I did, why and in what order:

1. Before synchronizing data, you need to check whether there is a connection to the server at all; for this we do the following:

Let's check the connection = """" + WinSCP Path + """" + " /console /command " + """option batch abort"" " + """open " + WinSCP Profile + """ " + " ""close"" ""exit""";

net.Run(Check Connection, 0, True);

where PathWinSCP - string - path to the program (c:\Program Files (x86)\WinSCP\WinSCP.com, PLEASE NOTE that the file extension must be com), ProfileWinSCP - string - session profile, how you named your session, to example test_sFTP.

2. After we have executed the previous command, I strongly recommend doing the following, searching for the WinSCP log by date and checking it to see if there was an error in the connection, there are many options for how to do this, but I did this: from the end of the text I looked for the line “Failed” , until we found “Session name: " + ProfileWinSCP”, after that we interrupt the search, and in fact, if the “Failed” line was detected, then there was an error during the connection.

3. Synchronize files:

String Synchronization = """" + WinSCP Path + """" + " /console /command " + """option batch abort"" " + """open " + WinSCP Profile + """ " + """synchronize both " + CatalogOnServer1C + " " + CatalogOnSFTPServer + """ " + """ close"" ""exit""";

net = New COMObject("WScript.Shell");

net.Run(StringSync, 0, True);

After this, we check the log again.

Other commands you may need:

Write a file to the SFTP server:

Program String = """" + WinSCP Path + """" + " /console /command " + """option batch abort"" " + """open " + WinSCP Profile + """ " + """put " + DirectoryOnServer1C + "\" +FileName + " " + DirectoryOnSFTPServer + "/" + FileName + """ " + """close"" ""exit""";

net = New COMObject("WScript.Shell");

Copy a file from the SFTP server:

Program String = """" + WinSCP Path + """" + " /console /command " + """option batch abort"" " + """open " + WinSCP Profile + """ " + """get " + DirectoryOnSFTPServer + "/" + FileNameStr + " " + DirectoryOnServer1C + "\" + """ " + """close"" ""exit""";

net = New COMObject("WScript.Shell");

net.Run(Program Line, 0, True);

Get a list of files on the SFTP server and write it to a file:

Program String = "cmd.exe /c """"" + WinSCP Path + """ /console /command " + """option batch abort"" " + """open " +WinSCP Profile + """ " + "" "ls " + DirectoryOnSFTPServer + """""" + """ " + """ close""" + " > FMfiles.txt 2>&1" + """ " + """ exit""";

LaunchApplication(ProgramString,LogPath,True,ReturnCode);


This article presents ways to work around Internet connection errors that I use in practice.

In my case, the problem was solved by editing the file C:\WINDOWS\system32\drivers\etc\hosts "192.168.0.1 site domain name" on the client or server - where the routine task runs. After this, the built-in 1C Internet connections started working:

ExchangeFileDirectory = "D:\temp\"; ResponseFileName = ExchangeFileDirectory + "cards.xml"; Headers = "discount.php"; Proxy = Undefined; Try Proxy = New InternetProxy; ProxyK.Set("http", ProxyK.Server("http"), ProxyK.Port("http")); Exception EndTry; ProxyC.User = "**********"; Proxy.Password = "************"; Connect = New HTTPConnection("site domain name", Proxy); Attempt Connect.Get(Headers,ResponseFileName); Connect = Undefined; Exception Error = ErrorDescription(); Ф = New TextDocument; F.AddRow(Error); F.Write(ResponseFileName); Ф = ""; EndAttempt;

Editing etc\hosts also helped, after which the connection from the publication Sending an HTTP string with response processing started working

Trying XMLHttp = GetCOMObject("", "Microsoft.XMLHTTP"); Exception Error = ErrorDescription(); Ф = New TextDocument; F.AddRow(Error); F.Write("D:\temp\cards21.txt"); Ф = ""; Return; EndAttempt; Attempt XMLHttp.Open("GET", "http://sitedomainname/discount.php", False); Exception Error = ErrorDescription(); Ф = New TextDocument; F.AddRow(Error); F.Write("D:\temp\cards22.txt"); Ф = ""; Return; EndAttempt; XMLHttp.Send(); If XMLHttp.Status = 200 Then Str = ""; TryStr = XMLHttp.ResponseText; Exception Page = ErrorDescription(); EndAttempt; Ф = New TextDocument; F.AddRow(Str); F.Write("D:\temp\cards23.txt"); Ф = ""; Otherwise F = New TextDocument; F.AddRow(XMLHttp.Status); F.Write("D:\temp\cards24.txt"); Ф = ""; endIf;

The connection works fine through the dialmail component, but we couldn’t get it to work:

//If Load External Component(IB Catalog() + "DialMail.dll") = 0 Then // Report("Failed to load component DialMail.dll!"); //Return Status(0); // Return; //EndIf; //Attempt // FTP = CreateObject("AddIn.FTP"); // FTP.LogFileName = "c:\dialmail_ftp.log"; // FTP.VestiLogFile = 1; // FTP.NewTechnicalLogFile = 1; //Exception // Report("Could not create an object from the DialMail.dll component!"); //Return Status(0); // Return; //EndAttempt; //FTP.ProxyUserName = ProxyUserName; //FTP.PasswordProxy = PasswordProxy; //FTP.HostProxy = HostProxy; //FTP.PortProxy = PortProxy; //// If FTP.UseProxy = 0 then //// all the above parameters are not taken into account //FTP.UseProxy = 2; //FTP.UseSSL = 0; //FTP.NewRFC = 0; //FTP.BinaryMode = 0; //FTP.TimeBeforeBreak = 1000000; // Timeout //If FTP.Connect(FTPServer, // FTPPort, // FTPUser, // FTPPassword, 0) = 0 Then // Warning("Could not connect to the FTP server"); //Else //Connected = 1; //EndIf; //Notify(FTP.StringObjectVersion); //TechFTPDirectory = FTP.CurrentDirectory();

03/28/13 13:44:01.500 FTP: Connect to the socket
03/28/13 13:44:01.515 FTP: Connected to the socket successfully
03/28/13 13:44:01.671 FTP 03/28/13 13:44:01.671 FTP --> USER 931013677
03/28/13 13:44:01.687 FTP 03/28/13 13:44:01.687 FTP --> PASS *****
03/28/13 13:44:01.703 FTP 03/28/13 13:44:01.703 FTP --> TYPE I
03/28/13 13:44:01.718 FTP 03/28/13 13:44:01.718 FTP --> STRU F
03/28/13 13:44:01.734 FTP 03/28/13 13:44:01.734 FTP --> REST 0
03/28/13 13:44:01.734 FTP 03/28/13 13:44:01.750 FTP --> REST 1
03/28/13 13:44:01.750 FTP 03/28/13 13:44:01.765 FTP --> REST 0
03/28/13 13:44:01.765 FTP 03/28/13 13:44:01.781 FTP --> PWD
03/28/13 13:44:01.781 FTP 03/28/13 13:44:02.968 FTP --> PWD
03/28/13 13:44:02.984 FTP 03/28/13 13:44:02.984 FTP --> PASV
03/28/13 13:44:03.000 FTP03/28/13 13:44:03.000 FTP --> LIST

When I try to upload a file to the server, I get socket errors 10054

Socket Error #10054 Connection reset by peer

There is little written about this dialmail error on the Internet, mainly that it occurs, without a solution. On Gilev’s website it is written about this error that it occurs in the platform: http://www.gilev.ru/10054/

My way:

  1. winscp downloads the file (works even without editing etc\hosts)
  2. The http link jerks with curl (although curl does not work without editing etc\hosts)

Here is a list of the main fundamental issues when solving the practical problem of using an Internet connection using an external client, which turned out to be important to pay attention to...

I learned about curl from the specialists at pradata.com
curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of others

The publication Uploading files to SFTP helped about winscp

DNS address decoding may be disabled on the server (as in my case), so instead of the domain name of the site, use a digital IP address.

The text of the procedure that actually works for me (I overwrite the file in a temporary local directory and upload it to the server):
Procedure Report(TabDoc, DataCon, DateStart) Export F = New TextDocument; F.AddLine("BarCode;Period;Purchase Amount"); File="d:\temp\discount.txt"; F.Write(File); // http://programna1c.narod.ru/docs/WSH/1C_WSH_WshShell.html //Run(,) Executes the command. The main advantage is the presence of waiting for the completion of the executed command. //Parameters: // - the command to be executed. It is specified in DOS format and does not support long names. // - a number indicating the option for displaying the window of the application being launched. Not required. Possible values: //0 - Hides a window and activates another; //1 - Activates and displays the window. If a window is minimized or maximized, the system restores it to its original size and position. Used when opening the program window for the first time. //2 - Activates the window in minimized mode. //3 - Activates the window and expands it to full screen. //4 - Shows the window in its new size and position. The current window remains active. //5 - Activates the window and shows it in the current size. //6 - Minimizes the window and activates the following on the taskbar. //7 - Shows the window as minimized. The active window remains active. //8 - Shows the window in its current state. The active window remains active. //9 - Activates and displays the window. If a window is minimized or maximized, the system restores it to its original size and position. Used to restore a minimized window. //10 - shows the window in the same state as the calling program window. // - flag for waiting for process completion. Possible values: 0 - do not wait for the command to complete execution; -1 - wait for the command to complete execution. Not required. Default is 0. //Note: You can run both the application and any command (similar to Start->Run). //Example: //WshShell = New COMObject("WScript.Shell"); //WshShell.Run("notepad",7,-1); WshShell = New COMObject("wscript.Shell"); //Contents of the ap.ini file //open ftp://******:********@****************** // rm discount.txt //option transfer ascii //put D:\temp\discount.txt //close //exit CommandLine = "" ReturnValue = WshShell.Run(CommandLine, 1); WshShell = Undefined; End of Procedure

Here is what applies to the external ftp client:

Command to run the script:

D:\temp\WinSCP.com /script=D:\temp\ap.ini

Script text:

open ftp://**************:**************@*************** ****** // after the dog the IP address, not the domain name
option transfer ascii
rm discount.txt
put D:\temp\discount.txt
close
exit

The result of running this script:

D:\temp>D:\temp\WinSCP.com /script=D:\temp\ap.ini
Connecting to ***************** ...
Connected with *********************. Waiting for welcome message...
Connected
Starting the session...
Reading remote directory...
Session started.
Active session: ************@**********************
transfer ascii
discount.txt
D:\temp\discount.txt | 42 KiB | 39.1 KiB/s | ascii | 100%
Session "****************@***************" closed.
No session.

I solved my problems using the WinSCP.com client, thanks to the publication Uploading files to SFTP