一个弱弱的问题:在web页面中使用socket

应用场景:
类似于网盘一个web项目,通过浏览器可以查看到个人的文件资料,并且要实现文件的上传下载。
但是老大的要求是:用socket走自定义协议与服务器通信,不能再添加新的web服务器,因为现在的服务器端就是用的nginx。
我的理解就是相当于在web页面中使用socket与服务器通信,不知道对不对?
老大对web开发不懂,我说这个必须要用一个tomcat,他非说不行。
望web牛人给个指点啊?

4个回答

关于tomcat单点故障的问题,这个其实是可以解决的,既然nginx都可以集群,那tomcat也可以,集群的一个目的是提高处理能力,另外个目的就是避免单点故障。只是针对tomcat的webapp来说,集群相对复杂一些,如果能保持webapp在服务器端无状态化的话,那这种集群和nginx的就没有太大区别了。
要想不改变你目前的架构方式,又要采用socket与nginx通讯的话,我个人觉得不太可能,因为浏览器只能使用HTTP协议通讯,其他的通讯协议对浏览器来说都不是默认支持,即时使用websocket,那也需要服务器端支持。至于其他的协议的支持,一般都使用给浏览器增加插件,比如ActiveX,flash,或者applet等,不过这些技术现在都不提倡使用,在移动环境下更是不会用。
所以,我建议你和你老大说明一下,既然不想改变服务器端架构,而且目前也有了nginx,那直接采用http协议就好了,为什么一定要用socket通讯呢?他这样做的目的是什么?

[quote]用socket走自定义协议与服务器通信[/quote]
这里的“服务器”是指什么?
既然是通过网页访问,那肯定需要web服务器,目前你们的nginx难道只服务静态内容吗?只要是动态交互都需要应用服务器,无论是php,java,.net等。
你可以和你老大具体沟通一下,了解清楚他期望的实现方式,或者他的真正意图。

是的...servlet需要一个java容器来解释.

web socket在不同的浏览器表现可能有差异.只是可能哈,具体没用过.

你的nginx已经支持PHP了?那你完全可以用PHP搞定哈!

查阅一下相信你能搞定.

如果是我.我会把nginx与tomcat再拿来集成一下,用servlet来做.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
使用HttpClient时遇到的 java.net.SocketException: Socket closed异常

public static Object[] callService(String wsUrl, String method, Object... arg) { logger.info("---enter callService---"); DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient(wsUrl); HTTPConduit conduit = (HTTPConduit) client.getConduit(); HTTPClientPolicy policy = new HTTPClientPolicy(); long timeout = 10 * 60 * 1000;// policy.setConnectionTimeout(timeout); policy.setReceiveTimeout(timeout); conduit.setClient(policy); Object[] res = null; try { res = client.invoke(method, arg); } catch (Exception e) { e.printStackTrace(); logger.error("send msg failed" + e.getMessage()); } return res ; } [2018-12-20 17:37:16,021]-INFO (SoapClient.java:36)|---enter callService--- [2018-12-20 17:37:18,042]-INFO (JAXBUtils.java:719)|Created classes: com.yggdrasill.work.flow.common.web.ObjectFactory, com.yggdrasill.work.flow.common.web.ReqMainAccount, com.yggdrasill.work.flow.common.web.ReqMainAccountResponse [2018-12-20 17:37:19,893]-WARN (LogUtils.java:371)|Interceptor for {http://web.common.flow.work.yggdrasill.com}PartenerInfoImpService#{http://web.common.flow.work.yggdrasill.com}reqMainAccount has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Could not send Message. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310) at com.boco.mis.cxf.CXFServices.SoapClient.callService(SoapClient.java:41) at com.boco.mis.account.action.AccountAction.goSmp(AccountAction.java:135) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254) at com.boco.mss.plat.interceptor.ErrorInterceptor.intercept(ErrorInterceptor.java:25) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.boco.common.base.interceptor.LoginInterceptor.doFilter(LoginInterceptor.java:112) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: java.net.SocketException: SocketException invoking http://10.131.120.99:8088/workflow/ws/PartnerService: Socket Closed at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1422) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1407) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) ... 84 more Caused by: java.net.SocketException: Socket Closed at java.net.PlainSocketImpl.getOption(PlainSocketImpl.java:286) at java.net.Socket.getSoTimeout(Socket.java:1032) at sun.net.www.http.HttpClient.available(HttpClient.java:356) at sun.net.www.http.HttpClient.New(HttpClient.java:273) at sun.net.www.http.HttpClient.New(HttpClient.java:310) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:987) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:923) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1359) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1301) at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1379) ... 87 more org.apache.cxf.interceptor.Fault: Could not send Message. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310) at com.boco.mis.cxf.CXFServices.SoapClient.callService(SoapClient.java:41) at com.boco.mis.account.action.AccountAction.goSmp(AccountAction.java:135) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254) at com.boco.mss.plat.interceptor.ErrorInterceptor.intercept(ErrorInterceptor.java:25) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.boco.common.base.interceptor.LoginInterceptor.doFilter(LoginInterceptor.java:112) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: java.net.SocketException: SocketException invoking http://10.131.120.99:8088/workflow/ws/PartnerService: Socket Closed at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1422) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1407) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) ... 84 more Caused by: java.net.SocketException: Socket Closed at java.net.PlainSocketImpl.getOption(PlainSocketImpl.java:286) at java.net.Socket.getSoTimeout(Socket.java:1032) at sun.net.www.http.HttpClient.available(HttpClient.java:356) at sun.net.www.http.HttpClient.New(HttpClient.java:273) at sun.net.www.http.HttpClient.New(HttpClient.java:310) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:987) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:923) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1359) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1301) at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1379) ... 87 more [2018-12-20 17:37:19,900]-ERROR (SoapClient.java:44)|send msg failedCould not send Message.

Error: socket hang up如何解决

server: const http = require("http"); const qs = require("querystring") http.createServer(function(request,response){ var body =""; request.on("data",function(chunk){ body+=chunk; }) request.on("end",function(){ response.writeHead(200,{"ContentType":"text/html;charset=utf-8"}); process.stdout.write("got name :"+ qs.parse(body)["name"]+"\n") }) }).listen(3000); client: var http = require("http"); var qs = require("querystring") function getname(theName){ var b = {name:theName}; console.log(b) var a=qs.stringify(b) console.log(typeof theName) console.log("theName:"+theName+" ,b转换为string后的a:"+a); var options = { hostname: '127.0.0.1', port: 3000, path: '/', method: 'POST', headers: { 'Content-Type':'application/x-www-form-urlencoded', 'Content-Length': a.length } }; http.request(options,function(response){ response.setEncoding('utf8'); var body =""; response.on('data', function(chunk){ body+=chunk; }); response.on('end',function (){ process.stdout.write("client compate!\n"); }) }).end(a); } process.stdin.on("data",function(inputData){ process.stdout.write("your name:"+inputData); console.log("输入内容: "+inputData+" 转换为string后:"+inputData.toString().replace("\n","")) getname(inputData.toString().replace("\n","")); }) 问题是:程序执行过4分钟左右报错,报错内容如下: events.js:141 throw er; // Unhandled 'error' event ^ Error: socket hang up at createHangUpError (_http_client.js:213:15) at Socket.socketOnEnd (_http_client.js:305:23) at emitNone (events.js:72:20) at Socket.emit (events.js:166:7) at endReadableNT (_stream_readable.js:923:12) at nextTickCallbackWith2Args (node.js:458:9) at process._tickCallback (node.js:372:17) Process finished with exit code 1

java.net.SocketException: socket closed

返回的httpresponse 内容如下 HTTP/1.1 200 OK [Server: zhihu_nginx, Date: Sun, 29 Sep 2013 02:08:35 GMT, Content-Type: application/json, Transfer-Encoding: chunked, Connection: keep-alive, Vary: Accept-Encoding, Expires: Fri, 02 Jan 2000 00:00:00 GMT, Pragma: no-cache, Cache-Control: private, no-store, max-age=0,no-cache, must-revalidate, post-check=0, pre-check=0] 报错如下: Exception in thread "main" java.net.SocketException: socket closed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136) at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152) at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:203) at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:174) at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137) at java.util.zip.InflaterInputStream.fill(Unknown Source) at java.util.zip.InflaterInputStream.read(Unknown Source) at java.util.zip.GZIPInputStream.read(Unknown Source) at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source) at sun.nio.cs.StreamDecoder.read(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at java.io.Reader.read(Unknown Source) at org.apache.http.util.EntityUtils.toString(EntityUtils.java:244) at org.apache.http.util.EntityUtils.toString(EntityUtils.java:288) at zhihu.ZhihuDownload.getAnswersList(ZhihuDownload.java:138) at zhihu.ZhihuDownload.main(ZhihuDownload.java:54)

github配置问题,Socket operation on non-socket

执行 $ ssh git@github.com 结果是这样的。。。 socket: Socket operation on non-socket ssh: connect to host github.com port 22: Socket operation on non-socket $ ssh -v 192.168.27.142 结果是这样的 OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to 192.168.27.142 [192.168.27.142] port 22. socket: Socket operation on non-socket ssh: connect to host 192.168.27.142 port 22: Socket operation on non-socket 求问到底为什么,这块不太懂啊

Connection reset by peer: socket write error

这个错误在网上能查到很多结果,但是我参照做都没有效果,现在问题依然存在,详细的错误信息如下 2014-05-01 21:46:37 -close connection error java.sql.SQLRecoverableException: IO 错误: Connection reset by peer: socket write error at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:587) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:4011) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at com.alibaba.druid.filter.FilterChainImpl.connection_close(FilterChainImpl.java:167) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.filter.stat.StatFilter.connection_close(StatFilter.java:254) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.filter.FilterChainImpl.connection_close(FilterChainImpl.java:163) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.close(ConnectionProxyImpl.java:115) ~[druid-1.0.0.jar:1.0.0] at com.alibaba.druid.util.JdbcUtils.close(JdbcUtils.java:82) ~[druid-1.0.0.jar:1.0.0] at com.alibaba.druid.pool.DruidDataSource.discardConnection(DruidDataSource.java:967) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:934) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4534) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4530) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:880) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872) [druid-1.0.0.jar:1.0.0] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97) [druid-1.0.0.jar:1.0.0] at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.getConnection(AbstractRoutingDataSource.java:162) [payplat-dacq-1.0-SNAPSHOT.jar:na] at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [payplat-dacq-1.0-SNAPSHOT.jar:na] at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [payplat-dacq-1.0-SNAPSHOT.jar:na] at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382) [payplat-dacq-1.0-SNAPSHOT.jar:na] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456) [payplat-dacq-1.0-SNAPSHOT.jar:na] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:464) [payplat-dacq-1.0-SNAPSHOT.jar:na] at com.payplat.util.jdbc.other.impl.JdbcServerImpl.meterList(JdbcServerImpl.java:88) [payplat-dacq-1.0-SNAPSHOT.jar:na] at com.smotive.action.DasControl.meterList(DasControl.java:52) [DasControl.class:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45] at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45] at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:920) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:816) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) [servlet-api.jar:na] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801) [spring-webmvc-3.2.1.RELEASE.jar:3.2.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) [servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) [catalina.jar:6.0.35] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:6.0.35] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:6.0.35] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:6.0.35] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [catalina.jar:6.0.35] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [catalina.jar:6.0.35] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina.jar:6.0.35] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [catalina.jar:6.0.35] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [catalina.jar:6.0.35] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) [catalina.jar:6.0.35] at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877) [tomcat-coyote.jar:6.0.35] at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594) [tomcat-coyote.jar:6.0.35] at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675) [tomcat-coyote.jar:6.0.35] at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] Caused by: java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.7.0_45] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:1.7.0_45] at java.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[na:1.7.0_45] at oracle.net.ns.DataPacket.send(DataPacket.java:210) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:230) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:321) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.net.ns.NetInputStream.read(NetInputStream.java:268) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.net.ns.NetInputStream.read(NetInputStream.java:190) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.net.ns.NetInputStream.read(NetInputStream.java:107) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:124) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:80) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1137) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:350) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4C7Ocommoncall.doOLOGOFF(T4C7Ocommoncall.java:61) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:574) ~[ojdbc6-11.2.0.3.0.jar:11.2.0.3.0] ... 55 common frames omitted 根据网上的说法,出现的Connection reset by peer: 原因可能是多方面的,不过更常见的原因是: ①:服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉; ②:客户关掉了浏览器,而服务器还在给客户端发送数据; ③:浏览器端按了Stop 2、3点可以排除,第一点让我觉得确实有问题,但是不知道该如何下手,还有一个问题就是,这个异常不是我手动捕获的,在我try catch前这个异常已经抛出,这个让我不解

java.net.SocketException: Socket is not connected

solr集群测试 package com.taotao.search; import java.io.IOException; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.CloudSolrServer; import org.apache.solr.common.SolrInputDocument; import org.junit.Test; public class SolrCloudTest { @Test public void testAddDocument() throws Exception { // 创建一个和solr集群的连接 // 参数就是zookeeper的地址列表,使用逗号分隔 String zkHost = "192.168.248.135:2181,192.168.248.135:2182,192.168.248.135:2183"; CloudSolrServer solrServer = new CloudSolrServer(zkHost); // 设置默认的collection solrServer.setDefaultCollection("collection2"); // 创建一个文档对象 SolrInputDocument document = new SolrInputDocument(); // 向文档中添加域 document.addField("id", "test001"); document.addField("item_title", "测试商品"); // 把文档添加到索引库 solrServer.add(document); // 提交 solrServer.commit(); } @Test public void deleteDocument() throws SolrServerException, IOException { // 创建一个和solr集群的连接 // 参数就是zookeeper的地址列表,使用逗号分隔 String zkHost = "192.168.248.135:2181,192.168.248.135:2182,192.168.248.135:2183"; CloudSolrServer solrServer = new CloudSolrServer(zkHost); // 设置默认的collection solrServer.setDefaultCollection("collection2"); solrServer.deleteByQuery("*:*"); solrServer.commit(); } } 出现异常 java.net.SocketException: Socket is not connected at sun.nio.ch.Net.translateToSocketException(Net.java:123) at sun.nio.ch.Net.translateException(Net.java:157) at sun.nio.ch.Net.translateException(Net.java:163) at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:401) at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:200) at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1110) Caused by: java.nio.channels.NotYetConnectedException at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:782) at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:399) ... 3 more

抛SocketException: Socket is not connected

想些一个聊天软件 pc端服务器和客户端都写好了,但是再写安卓端时老是会出现 W/System.err: java.net.SocketException: Socket is not connected W/System.err: at java.net.Socket.getOutputStream(Socket.java:921) W/System.err: at server.MyMessage.send(MyMessage.java:66) W/System.err: at com.example.linqijun.qaclient.MainPageActivity$Destory.run(MainPageActivity.java:132) W/System.err: at java.lang.Thread.run(Thread.java:761) 我是将注册页面的socket传到mainui上用的,结果会出这个问题,网上也查不到,第一次提问,不符合规矩的地方还请大大们原谅。 代码如下 ``` public class LoginActivity extends AppCompatActivity { private EditText accountEdit; private EditText passwordEdit; private Button loginB; private Button registerB; private Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); Toast.makeText(LoginActivity.this,msg.obj.toString(),Toast.LENGTH_SHORT).show(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_login); accountEdit = (EditText) findViewById(R.id.account); passwordEdit = (EditText) findViewById(R.id.password); registerB = (Button) findViewById(R.id.register); registerB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //启动注册 Intent intent = new Intent(LoginActivity.this,RegisterActivity.class); startActivity(intent); } }); loginB = (Button) findViewById(R.id.login); loginB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(accountEdit.getText().toString().equals("") || passwordEdit.getText().toString().equals("")){ Toast.makeText(LoginActivity.this,"can't be empty",Toast.LENGTH_SHORT).show(); return; } new Thread(new LoginThread()).start(); } }); } private class LoginThread implements Runnable{ private MySocket so; @Override public void run() { try { so = new MySocket("10.0.2.2",6870); double id = Double.parseDouble(accountEdit.getText().toString()); String password = passwordEdit.getText().toString(); User temp = new User(id,"0"); temp.setPassWord(password); MyMessage mgs = new MyMessage(temp); mgs.setType(1); mgs.send(so); DataInputStream dis = new DataInputStream(so.getInputStream()); ObjectInputStream ois = new ObjectInputStream(dis); MyMessage res = (MyMessage)ois.readObject(); if(res.getString().equals("success")){ //启动mainui activity User toNext = res.getUser(); Intent intent = new Intent(LoginActivity.this,MainPageActivity.class);//"extre data",toNext,so); Bundle bundle = new Bundle(); bundle.putSerializable("mgs",res); bundle.putSerializable("so",so); intent.putExtras(bundle); startActivity(intent); finish(); }else{ Message a = new Message(); a.obj = res.getString(); handler.sendMessage(a); } } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } while(true){ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } } } ``` 然后是mainui的代码 ``` public class MainPageActivity extends AppCompatActivity { private MyMessage mgs; private User u; private MySocket so; private ImageButton userHead ; private TextView userName ; private ListView friends; private ArrayList<User> friendList ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_main_page); Intent intent = getIntent(); mgs = (MyMessage) intent.getSerializableExtra("mgs"); so = (MySocket) intent.getSerializableExtra("so"); u = mgs.getUser(); friendList = u.getFriends(); //名字 String nameTemp = u.getName() + " ( "+ ((Double)u.getID()).toString() + " )"; userName = (TextView) findViewById(R.id.main_userName); userName.setText(nameTemp); //头像 userHead = (ImageButton)findViewById(R.id.main_head_photo); int photo = u.getPhotoType(); switch (photo){ case 0: userHead.setImageResource(R.drawable.f0); break; case 1: userHead.setImageResource(R.drawable.f1); break; case 2: userHead.setImageResource(R.drawable.f2); break; case 3: userHead.setImageResource(R.drawable.f3); break; case 4: userHead.setImageResource(R.drawable.f4); break; case 5: userHead.setImageResource(R.drawable.f5); break; case 6: userHead.setImageResource(R.drawable.f6); break; case 7: userHead.setImageResource(R.drawable.f7); break; case 8: userHead.setImageResource(R.drawable.f8); break; case 9: userHead.setImageResource(R.drawable.f9); break; case 10: userHead.setImageResource(R.drawable.f10); break; case 11: userHead.setImageResource(R.drawable.f11); break; } //好友列表 FriendAdapter adapter = new FriendAdapter(MainPageActivity.this,R.layout.friend_list,friendList); friends = (ListView)findViewById(R.id.main_friendList); friends.setAdapter(adapter); friends.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { User inTalk = friendList.get(position); } }); } @Override protected void onDestroy() { new Thread ( new Destory()).start(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } super.onDestroy(); } private class Destory implements Runnable{ @Override public void run() { MyMessage exitmsg = new MyMessage(u); exitmsg.setType(2); exitmsg.send(so); } } } ```

web项目运行一段时间就宕掉了,警告: processCallbacks status 2

以下是日志信息,请大家帮忙看下: 2014-05-07 20:03:57 Commons Daemon procrun stderr initialized 2014-5-7 20:03:59 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\search_online\standard-tomcat-6.0.29\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;c:\Ora10InstantClient\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Java\jdk1.6.0_21\lib;C:\Java\jdk1.6.0_21\bin;C:\Program Files\Dell\SysMgt\oma\bin;C:\Program Files\Dell\SysMgt\idrac;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\ 2014-5-7 20:03:59 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 761 ms 2014-5-7 20:03:59 org.apache.catalina.core.StandardService start 信息: Starting service EmpSearchPro 2014-5-7 20:03:59 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.29 2014-5-7 20:04:00 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 2014-5-7 20:04:02 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor host-manager.xml 2014-5-7 20:04:02 org.apache.catalina.startup.HostConfig deployDescriptor 信息: Deploying configuration descriptor manager.xml 2014-5-7 20:04:02 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory docs 2014-5-7 20:04:02 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory examples 2014-5-7 20:04:02 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextInitialized() 2014-5-7 20:04:02 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextInitialized() 2014-5-7 20:04:02 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory WebQuery 2014-5-7 20:04:03 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 2014-5-7 20:04:04 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2014-5-7 20:04:04 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/78 config=null 2014-5-7 20:04:04 org.apache.catalina.startup.Catalina start 信息: Server startup in 4629 ms 2014-5-8 9:59:06 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 9:59:08 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 9:59:30 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 10:24:51 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 10:24:53 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 10:24:56 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 10:25:11 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 17:43:01 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 17:44:40 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:18:41 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:19:02 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:19:14 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:20:06 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:22:07 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:22:46 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:23:06 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:34:39 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 18:35:24 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 20:00:44 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 20:01:29 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 20:01:57 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 20:02:25 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-8 20:02:52 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 9:35:57 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 10:44:22 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 11:38:34 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 11:38:39 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 12:48:51 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 13:29:28 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 13:30:33 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 13:30:43 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 16:07:07 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 16:07:07 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 16:15:35 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-9 18:22:24 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-10 12:35:22 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-10 13:45:59 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-10 13:48:08 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-10 13:48:38 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-10 13:48:49 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-10 13:49:08 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 13:07:58 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 13:09:47 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:32:39 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:33:11 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:34:14 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:34:32 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:40:08 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:42:42 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:43:31 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 14:46:53 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 16:04:39 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 16:06:31 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 16:47:14 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 16:48:04 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 16:49:08 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 16:50:33 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 17:04:46 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 17:05:49 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 17:23:43 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 17:24:52 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 19:01:26 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 19:04:00 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 19:04:01 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 19:04:01 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 19:10:35 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-11 19:11:05 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 10:38:58 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 12:02:52 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 12:03:17 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 15:11:51 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 15:55:16 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 15:55:54 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 15:55:55 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 15:56:20 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 16:29:55 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-12 17:09:33 org.apache.jk.common.ChannelSocket processConnection 警告: processCallbacks status 2 2014-5-13 8:59:49 org.apache.catalina.core.StandardService stop 信息: Stopping service EmpSearchPro 2014-5-13 8:59:49 org.apache.catalina.core.ApplicationContext log 信息: SessionListener: contextDestroyed() 2014-5-13 8:59:49 org.apache.catalina.core.ApplicationContext log 信息: ContextListener: contextDestroyed() 2014-5-13 8:59:50 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 2014-5-13 8:59:50 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 严重: The web application [/WebQuery] registered the JBDC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 2014-5-13 8:59:50 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap 严重: The web application [/WebQuery] created a ThreadLocal with key of type [null] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1ab1379]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@8b8c90]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak. 2014-5-13 8:59:51 org.apache.catalina.core.StandardWrapper unload 信息: Waiting for 538 instance(s) to be deallocated 2014-5-13 8:59:52 org.apache.catalina.core.StandardWrapper unload 信息: Waiting for 538 instance(s) to be deallocated 2014-5-13 8:59:53 org.apache.catalina.core.StandardWrapper unload 信息: Waiting for 538 instance(s) to be deallocated 2014-5-13 8:59:54 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 严重: The web application [] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 严重: The web application [] registered the JBDC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] appears to have started a thread named [AWT-Windows] but has failed to stop it. This is very likely to create a memory leak. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 2014-5-13 8:59:54 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 严重: The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation.

socket中使用InputStream的read方法

客户端使用OutputSteam发送字符串 如果服务端用如下代码,数组读不到客户端发的字符串 ServerSocket server = new ServerSocket(4444); Socket socket = server.accept(); InputStream is = socket.getInputStream(); byte[] receiveBytes = new byte[9999]; int index = 0; while(index<=9999){ int tmpLength = is.read(receiveBytes,index,9999-index); if(tmpLength==-1) break; index+=tmpLength; } 但是如果服务端使用如下代码,却能读到客户端发的字符串 ServerSocket server = new ServerSocket(4444); Socket socket = server.accept(); InputStream is = socket.getInputStream(); int a = is.read(); **为什么?是哪里写的问题,一直没找出来问题,大神们帮看下。**

socket write error,求大大help

在springmvc中后台返回给前端一个json时报了这个,不知道如何下手了 java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:568) at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:539) at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:427) at weblogic.servlet.internal.ChunkOutputWrapper.flush(ChunkOutputWrapper.java:188) at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamImpl.java:121) at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:180) at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:138) at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:80) at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:129) at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:69) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:115) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:647) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:603) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:859) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:883) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:792) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:83) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

在h5页面中,在 JavaScript 里如何调用 socket套接字 来发送数据

在js 里面指定 ip 和端口,调用socket发请求, 不是websocket,不是使用http或者ws协议,而是直接使用tcp或者udp。 想达到类似于使用java Socket套接字一样的效果,直接使用socket 的输入输出流。

java定时器超时后关闭socket出现socket closed 异常的问题

package my.start; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; import java.util.Timer; import java.util.TimerTask; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; //创建AutoStart类,让他实现ServletContextListener(服务程序上下文监听器)接口 //实现ServletContextListener接口需要重写contextDestroyed()和contextInitialized()两个方法 //记得要在web.xml文件中加入 // <listener> // <listener-class>my.test.AutoStart</listener-class> // </listener> //这样,tomcat在启动时,就会同时调用该接口的contextInitialized()方法 //在contextInitialized()方法中,开启一个线程,用soket监听一个端口,从而实现TCP通信 public class AutoStart extends HttpServlet{ private static final long serialVersionUID = 1L; private int soketPort = 9014;//要监听的服务器端口,可以根据需要进行修改 @Override public void init() throws ServletException { // TODO Auto-generated method stub super.init(); new MyThread().start();//创建一个MyThread线程对象,并启动线程 System.out.println("开启监听线程"); } //创建MyThread类,继承Thread方法 class MyThread extends Thread { //重写Thread类的run()方法,用来实现MyThread线程的功能 public void run() { //System.out.println("测试开始"); try { ServerSocket ss = new ServerSocket(soketPort); System.out.println("监听到"+(soketPort+"")+"端口"); while(true){ //System.out.println("已经创建soket"); //ss对象的accept()方法可以监听指定端口有没有TCP连接 //在没有TCP连接之前程序将阻塞在这里 Socket socket = ss.accept(); System.out.println("有客户端接入"); //监听到指定端口有TCP连接后,创建soket对象,程序不再堵塞,往下执行 //创建一个线程,去监听客户端通过TCP发来的数据 Thread sockThread=new SocketTherad(socket); //启动线程 sockThread.start(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } int timeNum; class SocketTherad extends Thread{ //继承Thread类来创建线程 Socket socket; InputStream is; OutputStream os; boolean run_flag=true;//控制run()函数是否继续运行标志位 Timer heartBeatTimer = new Timer(); //心跳包定时器 private void startHeartBeatThread() { TimerTask heartBeatTask = new TimerTask() { public void run() { timeNum++; System.out.println("timerNum="+(timeNum+"")); if(timeNum==2){//超时则关闭socket连接及定时器 try { is.close(); os.close();//关闭输出流 socket.close();//关闭soket run_flag=false;//跳出死循环 System.out.println("TCP连接断开"); heartBeatTimer.cancel();//关闭定时器 } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }; heartBeatTimer.schedule(heartBeatTask, 10*1000, 10*1000); } public SocketTherad(Socket socket) { this.socket = socket;//传递过来的soket参数赋予给socket对象 } public void run() {//run()函数用来实现线程要完成的任务 startHeartBeatThread(); while(run_flag) { try { String str = null; is = socket.getInputStream();//获取输入流 os=socket.getOutputStream(); byte[] buffer = new byte[200];//数据缓冲区; int length=0; length = is.read(buffer);//读取接收到的数据流长度 if(length != (-1)){//不是-1,说明读取到有效的数据 str = new String(buffer,0,length);//输入流转换成str字符串 System.out.print("收到数据:"); System.out.println(str); } else if(length == (-1)){//接收到数据长度为-1,说明客户端主动关闭了TCP连接 is.close();//关闭输入流 os.close();//关闭输出流 socket.close();//关闭soket run_flag=false;//跳出死循环 System.out.println("TCP连接断开"); } buffer = null; System.gc();//垃圾回收 } catch (IOException e) { e.printStackTrace(); } } } } } ``` ```

socket中while(true)的使用

本人初学java编程,在书中看到这个语句,这个是服务端接受语句的代码 ``` package dddd; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.ServerSocket; import java.net.Socket; public class MyTcp { private BufferedReader reader; private ServerSocket server1; private ServerSocket server2; private Socket socket1; private Socket socket2; void getserver1(){ try{ server1=new ServerSocket(7993); System.out.println("服务器套接字已经创建成功"); while(true){ System.out.println("等待客户机链接"); socket1=server1.accept(); reader=new BufferedReader(new InputStreamReader(socket1.getInputStream())); getClientMessage(socket1); } }catch(Exception e){ e.printStackTrace(); } } private void getClientMessage(Socket socket){ try{ while(true){ System.out.println("来自客户机的信息:"+reader.readLine()); } }catch(Exception e){ e.printStackTrace(); } try{ if(reader!=null){ reader.close(); System.out.println("readerclose"); } if(socket!=null){ socket.close(); System.out.println("socketclose"); } }catch(IOException e){ e.printStackTrace(); } } public static void main(String[] args){ MyTcp tcp=new MyTcp(); tcp.getserver1(); } } ``` 这里面有两个while(true)都不太明白什么意思。按照我的理解在第二个语句 ``` while(true){ System.out.println("来自客户机的信息:"+reader.readLine()); } ``` 里面,system应该不断输出这个消息啊,但是结果system只是输出了一段消息 ![图片说明](https://img-ask.csdn.net/upload/201509/24/1443070801_437920.jpg) 我从客户端输入一次服务端便响应一次,程序没问题,就是想知道为何while(true)没有出现死循环。

Socket编程报这个异常 Connection reset:

![图片说明](https://img-ask.csdn.net/upload/201608/16/1471357157_874740.jpg) 上面是客户端代码 下面是服务器端代码,当服务器端执行Readline();就抛出Connection reset try { ServerSocket ss = new ServerSocket(6000); System.out.println("服务器已经对端口号为12002的端口进行监听"); while (true) { Socket socket = ss.accept(); System.out.println(socket.getRemoteSocketAddress() + "连接上服务器"); if (socket.isClosed()) { System.out.println("连接被关闭"); } System.out.println("OK"); InputStream is = socket.getInputStream(); BufferedReader br = new BufferedReader( new InputStreamReader(is)); // 获得输出流 OutputStream os = socket.getOutputStream(); PrintWriter pw = new PrintWriter(os); // 4.读取用户输入信息 String info = null; info = br.readLine(); while (!((info = br.readLine()) == null)) { System.out.println("我是服务器,用户信息为:" + info); } // 给客户一个响应 String reply = "welcome"; pw.write(reply); pw.flush(); // 5.关闭资源 pw.close(); os.close(); br.close(); is.close(); socket.close();

socket连接,偶尔发生这个异常,是什么原因引起的?

java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:196) at java.net.SocketInputStream.read(SocketInputStream.java:122) at java.net.SocketInputStream.read(SocketInputStream.java:108) at com.reapal.bipgw.biz.abc.util.Messenger2.sendBySoc(Messenger2.java:52) at com.reapal.bipgw.biz.abc.service.impl.AbcClientServiceImpl.sendReq(AbcClientServiceImpl.java:337) at com.reapal.bipgw.biz.abc.service.impl.AbcClientServiceImpl.isExist(AbcClientServiceImpl.java:197) at com.reapal.bipgw.biz.abc.service.impl.AbcClientServiceImpl.multiPay(AbcClientServiceImpl.java:82) at com.reapal.bipgw.web.controller.AbcController.multipay(AbcController.java:69) at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) at javax.servlet.http.HttpServlet.service(HttpServlet.java:646) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 这个异常不是一直发生,时好时坏,发送的报文在格式上应该不会存在问题.

Redis出现socket *:6379: bind: Address already in use

虚拟机是Centos,昨天执行 src/redis-server的时候,有出现同样的情况,上网查也不知道为什么,然后我重启了电脑之后居然能用了。今天想用java连接到 redis 服务,但是失败了,上网查,把redis.conf文件的bind 127.0.0.1给注释掉了, 然后就出现了Address already in use。把注释给去掉也不行了。 ![图片说明](https://img-ask.csdn.net/upload/201608/10/1470808672_45931.png)

JAVA中Socket对象如何重用多次?

试了一下,目前已知的 让socket发送流中的数据 只有一下三种方式 1.shutDown流 2.close流/close socket 3.sendUrgentData 前两种都会socket对象无法再次使用,如果想多次发送数据,只能用第3种。 有更优雅的方式实现socket重用吗?

import socket模块出现异常

不知道是什么原因,求解决办法,感谢!! >>> import socket Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in <module> udpSocket = socket.socket() TypeError: 'module' object is not callable Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module> from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module> from urllib.request import urlopen File "/usr/lib/python3.5/urllib/request.py", line 88, in <module> import http.client File "/usr/lib/python3.5/http/client.py", line 71, in <module> import email.parser File "/usr/lib/python3.5/email/parser.py", line 12, in <module> from email.feedparser import FeedParser, BytesFeedParser File "/usr/lib/python3.5/email/feedparser.py", line 27, in <module> from email import message File "/usr/lib/python3.5/email/message.py", line 16, in <module> from email import utils File "/usr/lib/python3.5/email/utils.py", line 29, in <module> import socket File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in <module> udpSocket = socket.socket() TypeError: 'module' object is not callable Original exception was: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in <module> udpSocket = socket.socket() TypeError: 'module' object is not callable

安卓 Socket通信,Socket连接不上,程序就在真机崩溃但在模拟器上正常

class ReceiveData extends Thread { int i=1; private void reconnect( ) { Log.i("第"+i+"次连接","reconnect刚开始执行"); try { Log.i("第"+i+"次连接","Socket之前"); Socket s=new Socket("192.168.0.103",40011); Log.i("第"+i+"次连接","Socket之后"); InputStream ins=s.getInputStream(); Log.i("第"+i+"次连接","InputStream之后"); BufferedReader br=new BufferedReader(new InputStreamReader(ins)); String data=null; Log.i("第"+i+"次连接","br之后"); i++; while((data=br.readLine())!=null) { String[] datas=data.split(","); Log.i("第"+i+"次连接","datas之后"); int dianping=Integer.parseInt(datas[0]); int zhiliang=Integer.parseInt(datas[1]); float jueduijiaodu=Float.parseFloat(datas[2]); float xiangduijiaodu=Float.parseFloat(datas[3]); // hcs.refresh(dianping,zhiliang); vcs.refresh(dianping,zhiliang ); disks.refresh(xiangduijiaodu, jueduijiaodu, dianping, zhiliang); cuslinear.refresh(jueduijiaodu, xiangduijiaodu, dianping, zhiliang); } }catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.i("第"+i+"次连接","可能没连接上"); reconnect(); } catch(Exception e) { e.printStackTrace(); } } public void run() { reconnect(); } } 在客户端的一个Activity中,启动以上线程用来接收数据,当IP地址不对时,当然也就连通不了,于是抛出异常,再重新reconnect( ) (应该没有什么问题吧?),但是在真机上反复出现几次 ![CSDN移动问答][1] [1]: http://www.eoeandroid.com/data/attachment/forum/201403/28/141758f958x35x1733zhqp.jpg 后(大约7、8秒钟的时间,而且不会其他那几条的输出,这个我懂,因为socket没建成,于是try语句块中Socket s=new Socket("192.168.0.103",40011)后的语句就不会再执行了),该Activity就会崩溃,返回到上一个Activity,而且貌似说有内存溢出问题 ![CSDN移动问答][1] [1]: http://www.eoeandroid.com/data/attachment/forum/201403/28/141914bmqym1ezqlqwugt1.jpg 而在模拟器上却不会出现这个问题。如果IP地址正确,连通了,能够正常接收数据了,也不会出现这个问题。这到底是怎么回事呢?

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

你以为这样写Java代码很6,但我看不懂

为了提高 Java 编程的技艺,我最近在 GitHub 上学习一些高手编写的代码。下面这一行代码(出自大牛之手)据说可以征服你的朋友,让他们觉得你写的代码很 6,来欣赏一下吧。 IntStream.range(1, 5).boxed().map(i -&gt; { System.out.print("Happy Birthday "); if (i == 3) return "dear NAME"...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

程序员是做全栈工程师好?还是专注一个领域好?

昨天,有位大一的同学私信我,说他要做全栈工程师。 我一听,这不害了孩子么,必须制止啊。 谁知,讲到最后,更确定了他做全栈程序员的梦想。 但凡做全栈工程师的,要么很惨,要么很牛! 但凡很牛的,绝不是一开始就是做全栈的! 全栈工程师听起来好听,但绝没有你想象的那么简单。 今天听我来给你唠,记得帮我点赞哦。 一、全栈工程师的职责 如果你学习编程的目的只是玩玩,那随意,想怎么学怎么学。...

立即提问
相关内容推荐