关于“HTTP/1.1 新建会话失败”问题的解决方案

本文介绍了当遇到“HTTP/1.1新建会话失败”错误导致ASP页面无法正常访问时的三种有效解决方法:重启IIS服务、结束w3wp.exe进程及重新启动DefaultAppPool。
部署运行你感兴趣的模型镜像

现象:访问时出现“HTTP/1.1 新建会话失败”,asp页面无法正常访问

 

解决方案:

(1)重启IIS服务;

(2)结束w3wp.exe进程;

(3)打开Internet 信息服务(IIS)管理器,展开应用程序池,把DefaultAppPool停止再启动;

您可能感兴趣的与本文相关的镜像

Dify

Dify

AI应用
Agent编排

Dify 是一款开源的大语言模型(LLM)应用开发平台,它结合了 后端即服务(Backend as a Service) 和LLMOps 的理念,让开发者能快速、高效地构建和部署生产级的生成式AI应用。 它提供了包含模型兼容支持、Prompt 编排界面、RAG 引擎、Agent 框架、工作流编排等核心技术栈,并且提供了易用的界面和API,让技术和非技术人员都能参与到AI应用的开发过程中

C:\Users\1>tasklist /fi "imagename eq java.exe" 映像名称 PID 会话会话# 内存使用 ========================= ======== ================ =========== ============ java.exe 22608 Console 1 12,800 K java.exe 27632 Console 1 213,388 K C:\Users\1>netstat -ano | findstr :8080 C:\Users\1>netstat -ano | findstr :8082 TCP 0.0.0.0:8082 0.0.0.0:0 LISTENING 27632 TCP [::]:8082 [::]:0 LISTENING 27632 TCP [::1]:8082 [::1]:62834 TIME_WAIT 0 TCP [::1]:8082 [::1]:62835 TIME_WAIT 0 C:\Users\1># 开放端口(管理员 PowerShell) '#' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 C:\Users\1>New-NetFirewallRule -DisplayName "Tomcat_Port" -Direction Inbound -LocalPort 8080 -Protocol TCP -Action Allow 'New-NetFirewallRule' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 C:\Users\1> <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!-- APR connector and OpenSSL support using Tomcat Native --> <Listener className="org.apache.catalina.core.AprLifecycleListener" /> <!-- OpenSSL support using FFM API from Java 22 --> <!-- <Listener className="org.apache.catalina.core.OpenSSLLifecycleListener" /> --> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 This connector uses the NIO implementation. The default SSLImplementation will depend on the presence of the APR/native library and the useOpenSSL attribute of the AprLifecycleListener. Either JSSE or OpenSSL style configuration may be used regardless of the SSLImplementation selected. JSSE style configuration is used below. --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" maxParameterCount="1000" > <SSLHostConfig> <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" certificateKeystorePassword="changeit" type="RSA" /> </SSLHostConfig> </Connector> --> <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2 This connector uses the APR/native implementation which always uses OpenSSL for TLS. Either JSSE or OpenSSL style configuration may be used. OpenSSL style configuration is used below. --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol" maxThreads="150" SSLEnabled="true" maxParameterCount="1000" > <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> <SSLHostConfig> <Certificate certificateKeyFile="conf/localhost-rsa-key.pem" certificateFile="conf/localhost-rsa-cert.pem" certificateChainFile="conf/localhost-rsa-chain.pem" type="RSA" /> </SSLHostConfig> </Connector> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <!-- <Connector protocol="AJP/1.3" address="::1" port="8009" redirectPort="8443" maxParameterCount="1000" /> --> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server> 给出修改后完整代码
06-24
<think>我们正在解决Tomcat的404错误,并配置端口和防火墙。用户要求配置Tomcat监听8082端口,同时允许防火墙访问8080和8082端口。但注意,用户提到404错误是关于找不到index.html,所以我们需要同时确保应用正确部署。根据之前的解决方案,我们分步骤进行:一、解决404错误(确保应用部署正确)1.确认应用已部署在webapps目录下,并且WAR包已解压(形成目录)。2.配置server.xml中的Context,确保上下文路径正确。二、修改Tomcat监听端口为8082(如果用户需要)三、配置防火墙允许8080和8082端口(尽管用户要求8080和8082,但实际我们可能只需要8082,但按用户要求两个都开)步骤详细说明:1.解决404错误:-检查webapps目录,确保存在应用目录(例如demo_0_0_1_SNAPSHOT)并且其中包含index.html。-如果没有自动解压,可以手动解压WAR包(jar命令)或重启Tomcat。-配置Context:在server.xml的<Host>标签内添加<Context>,将应用设置为默认访问(path="")或指定路径。2.修改监听端口:-编辑conf/server.xml,找到<Connectorport="8080"...>,将port改为8082。3.防火墙设置(Windows):-允许8080和8082端口的入站连接。注意:用户原来的错误信息中应用路径是/demo_0_0_1_SNAPSHOT_war/index.html,这通常意味着应用上下文是/demo_0_0_1_SNAPSHOT_war,但实际部署目录可能是demo_0_0_1_SNAPSHOT(不带_war)。因此,需要检查应用目录的实际名称。另外,如果用户希望直接通过根路径访问,可以配置Contextpath=""。具体步骤:步骤1:修改Tomcat监听端口(改为8082)-打开conf/server.xml-找到:<Connectorport="8080"protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443"/>-修改port="8080"为port="8082"步骤2:配置应用上下文(解决404)-在同一个server.xml文件中,在<Host>标签内添加Context(假设应用目录名为demo_0_0_1_SNAPSHOT):<Contextpath=""docBase="demo_0_0_1_SNAPSHOT"reloadable="true"/>这样配置后,访问http://localhost:8082/就会指向该应用的index.html。步骤3:防火墙设置-打开Windows防火墙高级设置-新建入站规则,分别允许TCP端口8080和8082或者使用PowerShell命令(管理员权限):```powershellNew-NetFirewallRule-DisplayName"Tomcat_Port_8080"-DirectionInbound-LocalPort8080-ProtocolTCP-ActionAllowNew-NetFirewallRule-DisplayName"Tomcat_Port_8082"-DirectionInbound-LocalPort8082-ProtocolTCP-ActionAllow```步骤4:重启Tomcat-执行bin/shutdown.bat(如果正在运行)-再执行bin/startup.bat验证:-访问http://localhost:8082/应该能看到index.html内容(如果配置了Contextpath="")-或者如果未配置Context,则访问http://localhost:8082/demo_0_0_1_SNAPSHOT/index.html注意:如果应用目录名称不是demo_0_0_1_SNAPSHOT,请替换为实际的目录名(去掉版本号后面的_war?通常WAR包解压后目录名和WAR文件名一致,但不包括.war后缀,且不会带_war后缀。例如,WAR包名为demo_0_0_1_SNAPSHOT.war,解压后目录为demo_0_0_1_SNAPSHOT。但用户错误信息中是/demo_0_0_1_SNAPSHOT_war/...,所以可能是构建时加了_war?需要确认实际目录名)如果实际目录名是demo_0_0_1_SNAPSHOT_war,那么docBase就写这个。因此,在配置Context之前,请先查看webapps目录下的实际目录名。如果用户希望保留原来的8080端口,则不需要修改端口,但用户要求修改为8082,所以我们修改端口。另外,防火墙配置两个端口是因为用户要求允许访问8080和8082,但实际上我们修改了Tomcat端口为8082,所以8080可能不再使用。但按用户要求,两个端口都允许。最后,生成相关问题。</think>### Tomcat HTTP 404 错误解决方案 #### 一、解决 404 错误(应用部署问题1. **检查应用部署目录** - 确认 WAR 包已解压到 `webapps` 目录: ```bash webapps/ └── demo_0_0_1_SNAPSHOT_war # 确保此目录存在 ├── WEB-INF ├── index.html # 验证目标文件存在 └── ... ``` - 若未自动解压,手动解压: ```bash cd $CATALINA_HOME/webapps jar -xvf demo_0_0_1_SNAPSHOT_war.war ``` 2. **配置上下文路径** 修改 `conf/server.xml`,在 `<Host>` 标签内添加: ```xml <Context path="/myapp" docBase="demo_0_0_1_SNAPSHOT_war" reloadable="true" /> ``` - `path="/myapp"` → 访问路径变为 `http://localhost:8082/myapp/index.html` - `docBase` 必须与 `webapps` 下的目录名完全一致 3. **设置默认应用** 若需直接访问根路径,改为: ```xml <Context path="" docBase="demo_0_0_1_SNAPSHOT_war" /> ``` 访问 `http://localhost:8082/` 即可打开 index.html #### 二、配置端口监听(8082端口) 1. **修改 server.xml** ```xml <!-- 找到 HTTP 连接器 --> <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> ``` - 将 `port` 从 `8080` 改为 `8082` - 保存后重启 Tomcat 2. **验证端口监听** ```bash # Linux/Mac netstat -an | grep 8082 # Windows netstat -ano | findstr :8082 ``` 应有 `LISTENING` 状态 #### 三、防火墙配置 1. **允许端口通过防火墙** ```powershell # Windows (管理员权限) New-NetFirewallRule -DisplayName "Tomcat_8080" -Direction Inbound -LocalPort 8080 -Protocol TCP -Action Allow New-NetFirewallRule -DisplayName "Tomcat_8082" -Direction Inbound -LocalPort 8082 -Protocol TCP -Action Allow ``` 2. **Linux 防火墙 (iptables)** ```bash sudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 8082 -j ACCEPT sudo service iptables save ``` #### 四、验证流程 1. **端口监听测试** ```bash curl -I http://localhost:8082 # 应返回 200 或 302 ``` 2. **应用访问测试** ```bash curl http://localhost:8082/myapp/index.html # 应返回 HTML 内容 ``` 3. **外部访问测试** ```bash curl http://your-server-ip:8082/myapp/ ``` #### 五、常见问题排查 ```mermaid graph TD A[404错误] --> B{文件是否存在?} B -->|是| C[检查Context配置] B -->|否| D[重新部署WAR] C --> E[验证path/docBase] E --> F[检查端口监听] F --> G[防火墙状态] G --> H[网络可达性] ``` > **关键点**: > - 路径大小写敏感:`/demo_0_0_1_SNAPSHOT_war` 必须与目录名完全匹配 > - 修改配置后必须重启 Tomcat > - 防火墙需同时放行入站/出站规则[^1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值