Problems FTPing FROM Azure to another FTP site - c#

I've tried using FtpWebRequest and EnterpriseDT.Net.Ftp on an Azure website where I want to pass a byte array from a FileUpload to another FTP site.
This works on local servers and hence will work on a VM but cannot get it working on an Azure website. Admittedly we're trying to avoid the costs of adding a VM or an additional Azure storage account.
It seems the port is blocked on Azure, yet it is open to us on local servers.
[IOException: Failed to connect to XXX.XXX.XXX.XXX:21 within timeout 120000 ms]
EnterpriseDT.Net.StandardSocket.InternalConnect(EndPoint remoteEP, Int32 timeout) +272
EnterpriseDT.Net.StandardSocket.Connect(EndPoint remoteEP, Int32 timeout) +350
EnterpriseDT.Net.Ftp.FTPControlSocket.ConnectSocket(BaseSocket socket, String address, Int32 port) +66
EnterpriseDT.Net.Ftp.FTPControlSocket.Initialize(BaseSocket sock, String remoteHost, Int32 controlPort, Int32 timeout, Encoding encoding) +57
EnterpriseDT.Net.Ftp.FTPClient.Connect(String remoteHost, Int32 controlPort, Int32 timeout) +407
EnterpriseDT.Net.Ftp.FTPClient.Connect() +43
EnterpriseDT.Net.Ftp.FTPConnection.Connect() +456
XXXXX.XXXXX.XXX.XXXXX.FtpUpload(String Id, FileUpload file, String ftpServer, String ftpUsername, String ftpPass, String domainName) +371
Does anyone know how this can be accomplished via .net FtpWebRequest or a third party library?

The FTP port (21) is blocked for an Azure website directly, if you use: ftp://{sitename}.azurewebsites.net, to get the proper FTP profile for that website you need to download it's publishing settings, there you'll find the address, user name and password.
Information on getting the publish profile is here: http://blogs.msdn.com/b/avkashchauhan/archive/2012/06/26/deploying-windows-azure-website-using-visual-studio-web-publish-wizard.aspx
I would also recommend you use the VFS endpoint of your scm site (https://{sitename}.scm.azurewebsites.net) to upload files, this way you use https protocol which is more reliable.
The VFS api:
https://github.com/projectkudu/kudu/wiki/REST-API#vfs
More about your scm site:
http://blogs.msdn.com/b/windowsazure/archive/2014/03/04/windows-azure-websites-online-tools-you-should-know-about.aspx

Related

Angular local SSL with universal does not work

I created an angular universal app and followed the following tutorial to use SSL for local development with SSR:
https://medium.com/#dnlcyan/local-angular-ssr-with-https-b9d305dc620d
The certificate is trusted in the browser and also the requests work on browser level. But for request coming from the node server the API throws the following exception:
Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware
Failed to authenticate HTTPS connection. System.IO.IOException:
Received an unexpected EOF or 0 bytes from the transport stream. at
System.Net.Security.SslStream.g__InternalFillHandshakeBufferAsync|189_0[TIOAdapter](TIOAdapter
adap, ValueTask`1 task, Int32 minSize) at
System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter
adapter) at
System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter
adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean
isApm) at
Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.OnConnectionAsync(ConnectionContext
context)
I read something about that the certificate might not be trusted, but I added it to windows and also the browser indicates that it's correct. I tried to create a new certificate according to this tutorial but it doesn't work as well: https://fmoralesdev.com/2020/01/03/serve-angular-app-over-https-using-angular-cli/
Does anyone know what the issue might be here?

.NET State server: Unable to make the session state request to the session state server

I had an issue with an existing app, so I created a brand new MVC app with no functionality other than reading session state, and I get the same issue.
With this line in the web.config:
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="20" />
I get this when the app runs and tries to utilize session:
"Unable to make the session state request to the session state server."
Full error stack and version info:
[HttpException (0x80070057): Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.]
System.Web.SessionState.OutOfProcSessionStateStore.MakeRequest(StateProtocolVerb verb, String id, StateProtocolExclusive exclusiveAccess, Int32 extraFlags, Int32 timeout, Int32 lockCookie, Byte[] buf, Int32 cb, Int32 networkTimeout, SessionNDMakeRequestResults& results) +3251784
System.Web.SessionState.OutOfProcSessionStateStore.DoGet(HttpContext context, String id, StateProtocolExclusive exclusiveAccess, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags) +169
System.Web.SessionState.OutOfProcSessionStateStore.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags) +26
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +111
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +778
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +254
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3160.0
I have verified the ASP.NET State Service is running, verified that the registry data is accurate, verified the firewall is turned off completely so the local port shouldn't be blocked, etc. What else can I do to verify connectivity with the state server, and what might be going on?
I tried to re-install Framework 4.5, but it was already installed so it didn't do anything. (The app uses Framework 4.5, btw).
I tried the old suggestions of using aspnet_regiis , but that has apparently not been an option in later Framework versions. I see the question asked a few times here, and in other places, but all of them are solved by steps I've already taken, so I'm not sure where to go from here.
Thanks for anyone who can help!
(Edit/addition:
I've also set AllowRemoteConnection to 1 in the registry.
And I verified the service seems to be listening:
C:\WINDOWS\system32>netstat -aon | find /i "42424"
TCP 0.0.0.0:42424 0.0.0.0:0 LISTENING 4256

TCP WCF Client as windows service connects only under administrator user privilege

I have been writing windows services for over a decade but this is my first with WCF TCP.
Problem:
In a client-server WCF TCP scenario (separate computers), server part works perfect. The client code also works perfect as console app, but when running the same code inside a windows service, it works only under Administrator user. Using Network Service or Local Service (as required for such usages) ends with the following error:
The socket connection was aborted. This could be caused by an error
processing your message or a receive timeout being exceeded by the remote
host, or an underlying network resource issue. Local socket timeout was
'00:00:59.8938785'.
An existing connection was forcibly closed by the remote host System
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size,
SocketFlags socketFlags)
at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32
offset, Int32 size, Boolean immediate, TimeSpan timeout)
System
at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32
offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Write(Byte[] buffer, Int32 offset,
Int32 count)
at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32
offset, Int32 size, Boolean immediate, TimeSpan timeout)
To simplify the situation, I wrote a WCF server as windows service which utilizes a simple [OperationContract] method which gets a string and echoes it back, so code is not a big deal. Also, this has nothing with timeout settings on server or client, but client user accounts.
Client part (console app and win service, under different users) tested on Windows 10 Pro and Windows Server 2003 with the same results. Server part resides on a Windows Server 2003. All in .Net 4.
Question:
A windows service under Administrator user is not an option, so how can I force WCF TCP client on windows service working under Local Service / Network Service?
Update
WCF tracing report in rar format
Update 2
Sample Project
Regards

C# network connection running from shared drive

I'm trying to read web resource fron within the C# code. Unfortunately the code is valid only when running from local drive and throws exception when running from network share (and that's what I need).
The underlying connection was closed: Unable to connect to the remote server.
in System.Net.HttpWebRequest.GetResponse()
.........
Caused by:
An invalid argument was supplied
in System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
in System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
in System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
in System.Net.Connection.CompleteStartConnection(Boolean async, HttpWebRequest httpWebRequest)
I've tried code similar to (this throws the exception):
request = (HttpWebRequest)WebRequest.Create(url);
as well as direct socket connection according to http://msdn.microsoft.com/en-us/library/2b86d684.
I have a suspicion there is some sort of security setting in Windows that prevents network connections. Is it possible to solve this? Via AD policy? Or something in my code?
You could start here The Project Location is Not Trusted Dialog Box. Quote:
By default, a UNC path is not a trusted location for a project. You can modify the security policy of the file share to prevent this dialog box from appearing. For more information, see Configuring Security Policy.

Deploying report shows an error

I'm using SSRS 2008 R2 for my reports.
I have been working in my local environment and there was no problem with deploying to the local server. Now I want to deploy all the reports to live server but when I try to deploy to the live server by changing the Target server url and then providing the user name and password. its showing the error. (I'm deploying from VS 2008)
===================================
Could not connect to the report server http://192.168.0.217/ReportServer. Verify that the TargetServerURL is valid and that you have the correct permissions to connect to the report server. (Microsoft SQL Server Report Designer)
===================================
The underlying connection was closed: An unexpected error occurred on a receive. (System.Web.Services)
------------------------------
Program Location:
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Microsoft.SqlServer.ReportingServices2006.ReportServiceAuthentication.GetAuthenticationMode()
at ReportServiceClient2010.CheckAuthenticated()
at Microsoft.ReportDesigner.Project.ReportClientManager.DetectEndpointAndAuthenticate(String url, ICredentials credentials, String& authCookieName, Cookie& authCookie, EndpointType& endpointType)
at Microsoft.ReportDesigner.Project.ReportClientManager.DetectEndpointAndAuthenticate(String url, ConnectionProperties& connectionProperties)
at Microsoft.ReportDesigner.Project.ReportClientManager.GetCredentials(String url, CancelFlag cancelFlag)
at Microsoft.ReportDesigner.Project.ReportProjectDeployer.PrepareDeploy()
===================================
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. (System)
------------------------------
Program Location:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
===================================
An existing connection was forcibly closed by the remote host (System)
------------------------------
Program Location:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
But Im able to browse the report server from my local machine by providing the credentials. Anyone knowsa solution for this?
Try this , should help mostly. Also try and see if you are able to upload reports one by one using the Upload facility on the SSRS server itself
http://www.sqlservercentral.com/Forums/Topic1135602-150-1.aspx#bm1135709

Categories