GVKun编程网logo

dwr session error 问题解决(dwr error modal is not defined)

21

在本文中,您将会了解到关于dwrsessionerror问题解决的新资讯,同时我们还将为您解释dwrerrormodalisnotdefined的相关在本文中,我们将带你探索dwrsessionerr

在本文中,您将会了解到关于dwr session error 问题解决的新资讯,同时我们还将为您解释dwr error modal is not defined的相关在本文中,我们将带你探索dwr session error 问题解决的奥秘,分析dwr error modal is not defined的特点,并给出一些关于4.Vue 跨域 session 问题解决、connection reset by peer, socket write error 问题解决、Dwarf Error: wrong version in compilation unit header (is 4,、dwr session error的实用技巧。

本文目录一览:

dwr session error 问题解决(dwr error modal is not defined)

这几天本来在找一个项目中的bug,谁知改着改着就又出现了一个莫名其妙的问题,那就是打开网页时出现session error 问题,为什么说莫名其妙呢,因为我原来写的时候前几个版本并没有出现这个问题,而今天却出现了,好了,不啰嗦了,先是解决方法吧,就是在web.xml中配置加入如下代码:


<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>warn</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>


为什么会出现这个问题,我在网上搜了一下,在http://hi.baidu.com/ngomail/item/82c7750cda3438ec34990238讲得很详细,所以我也不在这多说了。。。 总之,一个bug,学明白一个知识,感觉还是不错的。。。

4.Vue 跨域 session 问题解决

4.Vue 跨域 session 问题解决

1. 设置 koa2 服务器从本地代理转发
修改:项目 /config/index.js-->dev 中
proxyTable: {
''/api'': {
target: ''http://localhost:3000'',
changeOrigin: true,
pathRewrite: { // 需要 rewrite 重写的,如果在服务器端做了处理则可以不要这段
''^/api/'': ''''
}
}
},

//--------------------------------------------------
dev: {
env: require(''./dev.env''),
port: 8080,
autoOpenBrowser: true,
assetsSubDirectory: ''static'',
assetsPublicPath: ''/'',
proxyTable: {
''/api'': {
target: ''http://localhost:3000'',
changeOrigin: true,
pathRewrite: { // 需要 rewrite 重写的,如果在服务器端做了处理则可以不要这段
''^/api/'': ''''
}
}
},
//--------------------------------------------------

2.axios 访问路径改为:
axGet(''/api/hall/getRoomList'',{},function(res){
alert(res.data);
},function(err){
alert(err);
});

3. 一定要重启 vue 服务器

connection reset by peer, socket write error 问题解决

connection reset by peer, socket write error 问题解决

在开发文件上传功能时遇到了 connection reset by peer, socket write error 的错误

在网上搜索了一下,得到的原因有这些:

  1. 服务器的并发连接数超过了其承载量,服务器会将其中一些连接 Down 掉;
  2. 客户关掉了浏览器,而服务器还在给客户端发送数据;
  3. 浏览器端按了 Stop;

跟浏览器也没关系,因为这里上传文件使用的是 apache httpclient 在上传文件,而且 timeout 都设置比较长。

最后分析到的问题原因,出在服务端上。服务端是这么处理的:上传文件时在 header 里含有了文件信息,上传文件成功,记录文件相关信息在 DB;如果再次上传这个文件,根据 header 的文件信息在 DB 判断是否已经上传,如果确认是重复文件,则直接返回 “文件重复”。(这个业务设计有点 bug,暂时忽略)

但是现在却遇到重复上传时,客户端 httpclient 报了 “connection reset by peer, socket write error” 的错误。

由于在重复上传时,服务端只取了 header 就判断了文件重复直接 response 了,这个时候客户端还在 “欢快” 的传输文件呢,而服务端直接 response 把连接关闭了,所以客户端就懵逼了,报了错误。

修改上传文件,重新上传即可。

这个问题暂时还没有找到技术上如何解决(如果找到,后面再补充),所以在业务上进行解决的。在客户端遇到 SocketException 时,尝试重新上传前,先查询服务端是否已经完成了此文件的上传,如果已经存在,则不用重复上传了,也就可以避免因为重复上传导致的问题,毕竟重复上传也是为了保证在网络不佳时能补偿。

详细分析  : http://www.cnblogs.com/liqipeng/p/8639818.html

Dwarf Error: wrong version in compilation unit header (is 4,

Dwarf Error: wrong version in compilation unit header (is 4,

问题描述: 在gcc4.9,gdb7.0环境下,启动gdb时出现了如下错误:Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /dawnfs/users/ 出现此错误的原因主要是gcc4.9生成的调试信息是dawnfs4,而gdb7.0支持的是 dawnfs2

问题描述:在gcc4.9,gdb7.0环境下,启动gdb时出现了如下错误:dwarf error: wrong version in compilation unit header (is 4, should be 2) [in module /dawnfs/users/  出现此错误的原因主要是gcc4.9生成的调试信息是dawnfs4,而gdb7.0支持的是dawnfs2


解决方案:这个问题其实是编译环境的问题,可以更改gcc和gdb的版本,这需要去寻找合适的版本。当然也可以给gcc增加编译参数,使其生成dawnfs2调试信息,主要参数为-gdwarf-2 -gstrict-dwarf,做法如下:

在.bashrc中加入alias gcc=''gcc -gdwarf-2 -gstrict-dwarf'',重启终端使其生效

这样gdb可以使用,也不会出现上面的错误。


参考gcc文档:https://gcc.gnu.org/gcc-4.5/changes.html

dwr session error

dwr session error

在使用dwr的时候遇到了session error错误解决方法,就是在web.xml 中配置如下:
<!-- DWR servlet,生产环境应该Debug为false-->
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>warn</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
当中的那个
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>

是为处理这个问题而加入的,经验证的确好用。

这是同源策略的问题,为了WEB环境的安全,在WEB脚本语言中不允许读取不同源的数据,同源包括相同协议,相同域名和相同端口三个条件,可以看这里:
http://www.ynutx.net/raindesign/blog/archive/209.html
而Ajax的异步处理方式跳过了这个限制,为了安全限制,它设置为sameDomainAccess,
这里有些突破这种限制的方式:http://tech.it168.com/j/2007-07-19/200707191542718_1.shtml
以上是自己的理解,不当之处请指正....!

另外装载了一篇

使用的Dwr版本2.0
在一台服务器上的不同端口上部署了同样的程序(tomcat5.5.28 80端口,tomcat 5.5.28 8080端口)
使用浏览器先后登陆80,8080端口的程序,都不注销,保持会话状态。
然后浏览器切换到8080的一个使用了DWR ajax功能的页面上,浏览器弹出Session Error的提示。
但是,如果切换到80端口的程序上,同样进入到一个使用了dwr ajax技术的页面上,没有Session Error的提示。
问题诊断:
初步怀疑浏览器的问题。
检查浏览器的cookie中的jsessionid的值。因为我们知道,Http协议本身是无状态的,服务器标识同一次会话的过程就是借助于cookie中的某个值或者通过url重写的方式来实现。这也是jsp程序的session原理。
检查发现:cookie中存在2个sessionid项,sessionid的值不同。
因为站点地址相同,url也相同(除了端口不同外),因此,浏览器“误”认为是同一个程序,把缓存的cookie项都发送回了服务器。
然后再观测ajax请求的值,即http post或get的参数值如下:


callCount=1

page=/web/initRolePermission.action

httpSessionId=3F5F7D7C14D40667FF126DC6F9038EE5

scriptSessionId=5B2B53E512648E78C92393E052589CA3859

c0-scriptName=adminRolePerAction

c0-methodName=findPermission

c0-id=0

c0-param0=string:181

batchId=0

在这里,务必注意

httpSessionId=3F5F7D7C14D40667FF126DC6F9038EE5,实际上,一般情况下,httpSessionId和cookie中的jsession值是相同的。

至于dwr组件中,为什么要加上httpSessionId,这是因为dwr开发团队考虑到了跨站攻击问题。因此,通过验证dwr ajax请求中的httpSessionId值,

来防止跨站攻击。

在重现,诊断问题过程中,发现Session Error的信息是来自dwr ajax请求的响应中,抛出的异常是java.lang.SecurityException,因此可以怀疑这个错误信息是源于dwr源代码中的。

用Eclipse打开下载到的dwr源代码。搜索Session Error的信息,然后在org.directwebremoting.dwrp.Batch 类中找到了,其部分代码如下:

private void checkNotCsrfAttack(HttpServletRequest request,String sessionCookieName)

{

// A check to see that this isn't a csrf attack

// http://en.wikipedia.org/wiki/Cross-site_request_forgery

// http://www.tux.org/~peterw/csrf.txt

if (request.isRequestedSessionIdValid() && request.isRequestedSessionIdFromCookie())

{

String headerSessionId = request.getRequestedSessionId();

if (headerSessionId.length() > 0)

{

String bodySessionId = getHttpSessionId();

// normal case; if same session cookie is supplied by DWR and

// in HTTP header then all is ok

if (headerSessionId.equals(bodySessionId))

{

return;

}

// Weblogic adds creation time to the end of the incoming

// session cookie string (even for request.getRequestedSessionId()).

// Use the raw cookie instead

Cookie[] cookies = request.getCookies();

for (int i = 0; i < cookies.length; i++)

{

Cookie cookie = cookies[i];

if (cookie.getName().equals(sessionCookieName) &&

cookie.getValue().equals(bodySessionId))

{

return;

}

}

// Otherwise error

log.error("A request has been denied as a potential CSRF attack.");

throw new SecurityException("Session Error");

}

}

}

仔细分析这段代码,即使在上述问题情境环境中,也不会出现Session Error的错误。

然后反编译正在使用的dwr类文件,找到batch类,代码却不同,代码如下:

private void checkNotCsrfAttack(HttpServletRequest request)

{

if(request.isRequestedSessionIdValid() && request.isRequestedSessionIdFromCookie())

{

String headerSessionId = request.getRequestedSessionId();

if(headerSessionId.length() > 0)

{

String bodySessionId = getHttpSessionId();

if(!bodySessionId.startsWith(headerSessionId))

throw new SecurityException("Session Error");

}

}

}

该代码没有考虑到cookie中出现多个jsession的情况。

到此,问题就发现并解决。

 由于dwr低版本的bug引起的,升级dwr版本即解决此问题。

可能,读者还有一个疑问:为什么该问题只出现在8080端口上。

检查发现:80端口的cookie项(就是80端口产生的jsessionid出现在cookie项的最前面),这样在80端口上的程序访问中,dwr ajax请求中的httpSessionId和cookie项最前面的jsessionid值相同,在80端口上,就自然不会出现session error错误。
 
 
以上来自网络:http://blog.sina.com.cn/s/blog_5f044a4d010185pn.html

关于dwr session error 问题解决dwr error modal is not defined的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于4.Vue 跨域 session 问题解决、connection reset by peer, socket write error 问题解决、Dwarf Error: wrong version in compilation unit header (is 4,、dwr session error等相关知识的信息别忘了在本站进行查找喔。

本文标签: