Visual basic UploadFile cannot connect to remote server - vb.net

I tried to upload file via Visual Basic with UploadFile function.
In documentation I found this step:
My.Computer.Network.UploadFile(
"C:\My Documents\Order.txt",
"http://www.cohowinery.com/upload.aspx", "anonymous", "")
I tried it by myself, it works, but when the FTP ports (20,21) are disabled, it cannot works, and take an error, that is normal I know, but how to fix it? How to check the ports or, check the connection to FTP server before connection?
Generally I use:
If My.Computer.Network.IsAvailable Then...
but this works only with general of internet connection.
Any suggestions how to edit my code, to take down any error?

A simple Try/Catch should work.
Try
My.Computer.Network.UploadFile("","","","")
Catch ex As Exception
'Error happened
End Try

Related

"the rpc server is unavailable" when trying to do some process on local html file with autohotkey

I have written the script that accesses the local HTML file and does some job.
^+A::
;Convert HTML TO ASCIIDOC
Send ^c
copied := Clipboard
sleep 30
local := "file:///C:/Users/emre/Desktop/Tools/Note%20Taking%20Tools/Asciidoc%20Tools/HtmlToAsciidoc-master/to-asciidoc.html"
sleep 100
(pwb5 := ComObjCreate("InternetExplorer.Application")).Visible:=False
pwb5.navigate(local)
while pwb5.busy
sleep 15
WinActivate,ahk_class IEFrame
ControlFocus,ahk_class IEFrame
Send, !n
Send, {Enter}
pwb5.document.getElementByID("source").value=copied
pwb5.document.getElementByID("conversion-button").Click()
Sleep 3000
Clipboard=pwb5.document.getElementByID("target").value
Return
When I run this script I get following error:
I have done some research and try following things but neither of these work.Any advice appreciated.
Check 1
I have checked DCOM Server Process Launcher, Remote Procedure Call (RPC) and RPC Endpoint Mapper from services.msc.All their status is Running and their startup is set to Automatic.
Check 2
I have also checked "Remote Assistance" from Firewall
Check 3
I have also checked that "File and Printer Sharing for Microsoft Networks" and "Internet Protocol Version 6 (TCP/IPv6)" are enabled
Check 4
I have also checked "to switch the NIC from the default "NAT" to "Bridged Adapter" from Virtualbox settings.
MAYBE this will help. My issue sounds similar to yours. In my case, I have a vb.net program, part of which does something to the effect of the following:
Function LoadWebPage(i_IE As SHDocVw.InternetExplorer, i_URL As String) As Boolean
i_IE.navigate (i_URL)
Debug.Print (i_IE.ReadyState)
End Function
The navigate method ran fine. But once it got to the point of returning the ReadyState property, I was getting the "RPC Server is unavailable" error. This was only happening on one of the three machines I was using. On the machine with the problem, I ran through the steps (which I saw listed in many other sites as well) you mentioned in your question, with no improvement. But then I came across a suggestion to adjust the "Internet Explorer Options-->Settings-->Security-->Enable Protected Mode". Actually the site that helped me said to make sure that they are checked for all of the zones (i.e., Internet, Local intranet, Trusted sites, Restricted sites). Actually it was unchecking them all that resolved my issue. I went back to one of the other two machines (one of those where the script was running without error), and indeed, they were unchecked on that machine (not sure yet about the 3rd machine).
Fix for RPC Server Error when occuring with attempt at Internet Explorer Automation
In case that post doesn't outlast this response, their stated reason for this issue:
"The basic gist of it is when you cross a security domain (http to
https) the sandboxing system actually creates a new IE COM
object...The basic solution is to set all of the security modes in the
Security tab of Internet Settings to 'protected mode enabled'(sic) to
avoid losing COM objects."
Again, I think that may have been a typo on their part and that they meant that the boxes should be unchecked.

VisM with VB.net Connection "Server Receive Timed Out"

I added a VisM control into vb.net via adding a reference to VisM.ocx and adding it in my toolbox as an activeX control.
I added the following code in a button:
Try
'open the connection
AxVisM1.Connect("CN_IPTCP:127.0.0.1[57772]", "LIVEDATA")
'do stuff.
MsgBox("Cache is now active")
'close the connection
AxVisM1.DeleteConnection()
Catch ex As Exception
'close the connection
AxVisM1.DeleteConnection()
MsgBox(ex.ToString)
End Try
however when I run the application the connection hangs, followed by a messagebox that says "Server Receive Timed Out".
I have tried turning off my firewall, and even my antivirus. How will I resolve this? Also, is what I am trying an effective way to access GLOBALS variables in VB.net??
I'm not familiar with VisM, but you using wrong port, and this port only for web, try to change it to 1972, which is used by default. Your server may use another one. Your real port number you can find at System Management Portal on page About (link in the header), and parameter is - Superserver Port.

PUT Stream 0 Bytes

I am using Windows Explorer to test the WebDAV implementation I am adapting to our system. The implementation is using IIS Express and is launched by Visual Studio 2013. I turned off Windows Explorer's requirement for SSL with WebDAV so I can test basic authentication (which works).
The problem I am having is with the Write method of the DavFile implementation. I connect to the web folder, navigate to a sub folder, then attempt to copy a JPG file from a folder on my computer's hard drive, into the WebDAV sub folder (using Windows Explorer).
The attempt to copy up a file (854kb) fails. When I set a break point, I notice that the "segment" stream (one of the input parameters on the "write" method, shows 0 (zero) bytes length.
Any tips on how to debug this problem? What is the most likely cause of 0 byte in the stream?
Here are some ideas about how to understand what is going wrong:
Examine the server log for exceptions. By default it is called WebDAVLog.txt and located in \App_Data\WebDAV\Logs\ folder. Are there any exceptions in it? Check your server log and make sure all requests were successful.
Examine WebDAV requests with a Fiddler tool or any other debugging proxy. While all requests that reached the WebDAV server Engine are logged, if the request failed before hitting the Engine you will not see it in a log. Usually this happens if the request failed during authentication stage.
Note that to capture requests using Fiddler on 'localhost' you must use 'localhost.fiddler' instead of 'localhost' when connecting to server, for example: http://localhost.fiddler:1234.
Exclude any client side issues. Finally there could be issues with client software that you are using, including with Microsoft miniredirector. Try to access server from any other machine. To get the idea if the problem is on the client or server side try also to reproduce the issue on ajaxbrowser.com.
You can post a part of the WebDAVLog.txt or fiddler log here or send it to IT Hit, it may give the idea of what is wrong.

WebSocket4Net in SilverLight

I am trying to create a WebSocket client through WebSocket4Net with port 4503.However i could see the the WebSocket status only as "Connecting" as it is neither raising any exceptions nor proceeding further.I was able to throw the Exception OnError Event which states that
"An attempt was made to access a socket in a way forbidden by its access permissions"
Am i missing anything?. Any suggestions or link will be much helpful.Thanks in advance.
ws = new WebSocket("ws://localhost:4503/WSServer");
ws.Opened += new EventHandler<EventArgs>(ws_Opened);
ws.Open();
I've been getting this kind of error today with a different type of socket library. This may be an access permissions problem in Silverlight, but on the server side, I found that I had to shut down Visual Studio, and then launch it with admin permissions in order to start up the service. It's going to be something like that. If it is a Silverlight access permissions thing, you will want to try running it out of browser and turning on elevated trust.

Triggering 'connection reset by peer'

I would like to test the logging that happens in our app (an embedded ftp server) when a 'connection reset by peer' error occurs. This post explains the source of the error pretty well, but doesn't really explain how to cause one. Does anybody know a way to trigger this error for a TCP connection?
tcpkill seems to do the job well.