Following issue: Using the power shell script below works for transferring a .war file from Server A to Server B via the tomcat manager ONLY when size of the war file is somewhat below 4MB. Everything above that size fails with
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send. At C:\Temp\deploy.ps1:25 char:2 + (Invoke-WebRequest -InFile "C:\Temp\fancy.war" -URI "https: ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Code that I run via PowerShell on Server A is:
Set-PSDebug -Trace 1
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object
TrustAllCertsPolicy
$user = "admin"
$pass = "loveit"
$secpass = ConvertTo-SecureString $pass -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($user, $secpass)
(Invoke-WebRequest -InFile "C:\Temp\fancy.war" -URI "**https**://host99.some.domain:443/manager/text/deploy?path=/fancy&update=true" -Method PUT -Credential $credential -ContentType 'application/zip' -UseBasicParsing -TimeoutSec 120)
I also played around with the server.xml of the tomcat8 and web.xml of the tomcat manager as mentioned in the post How to deploy a war file in Tomcat 7
As seen, with 50 MB I am on the safe side.
\webapps\manager\WEB-INF\web.xml
<multipart-config>
<!-- 50MB max -->
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
server.xml
<Connector port="443" maxPostSize="67589953" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2" useServerCipherSuitesOrder="true" ciphers="TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" server="Web Server" minSpareThreads="25" allowTrace="true" keystoreFile="cert.pfx" keystorePass="" keystoreType="PKCS12" connectionTimeout="100000000" />
Thanks for your help!