繁体   English   中英

用户登录身份验证失败-WSO2身份服务器

[英]User Login Authentication Failure - WSO2 Identity Server

我们正在根据Secondary Userstore(JDBC Userstore)创建用户。 同样,我们在API Store中创建了一个名为MyApplication的应用程序。 当用户尝试通过调用WSO2提供的/token API登录到MyApplication ,即使使用正确的用户名(格式为TESTDOMAIN / testuser )和密码也是如此。 有时登录会由于返回400 Bad Request的响应而失败:

 {
        "error_description": "Error when handling event : PRE_AUTHENTICATION",
        "error": "invalid_grant"
 }

并且,在IDM Audit.log中,错误如下所示:

WARN {AUDIT_LOG}-  Initiator=wso2.system.user Action=Authentication Target=TESTDOMAIN/testuser Data=null Outcome=Failure  Error={"Error Message":"Un-expected error while pre-authenticating, Error when handling event : PRE_AUTHENTICATION","Error Code":"31002"}

尝试登录5次后,用户将成功登录,没有任何问题。 我没有任何线索,也不了解为什么这种登录失败是随机发生的。

请提供有关此问题的解决方案/想法。

更新:

在启用用户核心调试日志和一些其他与此问题相关的日志之后。 在身份验证失败期间,我可以看到以下wso2carbon.log:

DEBUG {org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager} -  Error occurred while checking existence of values.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 733,140 milliseconds ago.  The last packet sent successfully to the server was 733,140 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        Caused by: java.net.SocketException: Connection reset
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:115)
        ... 113 more
DEBUG {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer} -  Error occurred while validating grant
org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception: Error when handling event : PRE_AUTHENTICATION
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 733,140 milliseconds ago.  The last packet sent successfully to the server was 733,140 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

如@senthalan在评论中所述,让我们尝试在连接URL的末尾添加“ autoReconnect = true”。

此外,请在master-datasources.xml中验证您的MySQL数据源的连接配置下是否具有以下建议值。 (如[1]中所述)

<definition type="RDBMS">
   <configuration>
       <url>jdbc:mysql://localhost:3306/umdb?autoReconnect=true</url>
       <username>regadmin</username>
       <password>regadmin</password>
       <driverClassName>com.mysql.jdbc.Driver</driverClassName>
       <maxActive>80</maxActive>
       <maxWait>60000</maxWait>
       <minIdle>5</minIdle>
       <testOnBorrow>true</testOnBorrow>
       <validationQuery>SELECT 1</validationQuery>
       <validationInterval>30000</validationInterval>
       <defaultAutoCommit>false</defaultAutoCommit>

另外,我们可以增加DB端的max_connections数量,如[2]中所述。

mysql> SET GLOBAL max_connections = 500;
Query OK, 0 rows affected (0.00 sec)

[1] https://docs.wso2.com/display/ADMIN44x/Changing+to+MySQL

[2] https://stackoverflow.com/a/19991390/2910841

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM