gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 09:34:46 24 4
gpt4 key购买 nike

我们在辅助用户存储(JDBC 用户存储)下创建用户。。同样,我们在 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 在评论中所述,让我们尝试将“autoReconnect=true”添加到连接 URL 的末尾。

此外,请验证 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>

此外,我们还可以增加数据库端的 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

关于mysql - 用户登录身份验证失败 - WSO2 身份服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57872028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com