Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信accesstoken是不是会过期 #63

Open
gp2852 opened this issue May 16, 2023 · 0 comments
Open

微信accesstoken是不是会过期 #63

gp2852 opened this issue May 16, 2023 · 0 comments

Comments

@gp2852
Copy link

gp2852 commented May 16, 2023

你好,我用的版本是
<dependency> <groupId>com.github.binarywang</groupId> <artifactId>weixin-java-miniapp</artifactId> <version>4.4.4.B</version> </dependency>
目前是将accesstoken存储在redis中,过期时间是7200秒;但是请求微信接口的时候时不时会报accesstoken过期,但是redis中accesstoken未过期(有时候还剩6000多秒),一天会出现两三次这种情况,每次都必须手动删除redis数据
`
@DaTa
@configuration
@ConfigurationProperties(prefix = "wx.login")
public class WxMiniAppConfig {

private String appId;
private String appSecret;

private static final String keyPrefix = "miniapp:wx";

@Resource
private RedissonClient redissonClient;

/**
 *  单机版
 * @return
 */
//@Bean
//public WxMaConfig wxMaConfig() {
//    WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
//    config.setAppid(appId);
//    config.setSecret(appSecret);
//    return config;
//}

/**
 * 分布式版
 *
 * @return
 */
@Bean
public WxMaConfig wxMaConfig() {
    WxMaDefaultConfigImpl config = new WxMaRedissonConfigImpl(redissonClient, keyPrefix);
    config.setAppid(appId);
    config.setSecret(appSecret);
    config.setExpiresTime(60*60);
    return config;
}

@Bean
public WxMaService wxMaService(WxMaConfig maConfig) {
    WxMaService service = new WxMaServiceImpl();
    service.setWxMaConfig(maConfig);
    return service;
}

}
`
我在配置文件中设置redis过期时间为1小时,但是这个设置没有起作用,目前已排除了其他程序同时在请求小程序的accesstoken;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant