当前位置: 首页 > news >正文

容器多机部署eureka及相关集群服务出现 Request execution failed with message: AuthScheme is null

预期部署方案:两个eureka+三个相关应用

注册时应用出现:Request execution failed with message: Cannot invoke “Object.getClass()” because “authScheme” is null,一开始认为未正确传递eureka配置的账户+密码,例:defaultZone: http://username:password@dev.bab.cn:8761/eureka/,检查后发现一切正常,后续排查后得出结论容器内部署hostname不能是127.0.0.1,必须为容器内ip(本次直接配置的是外部转发域名),调整为hostname: ${POD_IP},当然也可能是受多个因素影响,如集群网络不通、端口或eureka启动端口配置不正确等:

spring:security:basic:enabled: trueuser:name: eurekapassword: abc123456eureka:datacenter: user-serverenvironment: prodinstance:hostname: ${POD_IP}  # 容器部署必须填写docker容器的ipinstance-id: ${random.uuid}client:#    For stand-alone deployment, the following is false 单机部署的话以下为falseregister-with-eureka: ${IS_CLUSTERED:false}fetch-registry: ${IS_CLUSTERED:false}service-url:defaultZone: http://eureka:abc123456@bab.com/eureka/

网上其他说法总结:

  • 降级jdk到8(本次是openjdk17)
  • 升级spring core(本次spring boot3.0,core已经达到6.0)
  • 添加禁用csrf:
    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception 			{http.csrf().disable().httpBasic();return http.build();
    }
    
  • 禁用csrf方案2(来自stack overflow):
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {http.csrf(AbstractHttpConfigurer::disable).authorizeHttpRequests(authConfig -> authConfig.anyRequest().authenticated()).httpBasic(httpBasic -> {}).logout(logout -> {logout.logoutUrl("/logout");logout.addLogoutHandler((request, response, authentication) -> authentication.setAuthenticated(false));});return http.build();
    }
    
  • 禁用csrf方案3:
    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {http.csrf().disable().authorizeHttpRequests().anyRequest().authenticated() // 任何请求都不需要认证:.anyRequest().permitAll().and().httpBasic();return http.build();
    }
    

以上办法都没有成功,而且还导致额外出现Root name ‘timestamp’ does not match expected错误。

遇到的其他问题:eureka存在两个实例时相关服务注册完成后自动断开,排查后因为两个eureka没有将register-with-eureka和etch-registry同时设置为true,且defaultZone的地址不是相互注册状态eureka1填写eureka2的ip、eureka2填写eureka1的ip,可减少为1台或重新配置defaultZone的ip

http://www.lryc.cn/news/366247.html

相关文章:

  • Qt Graphics View Framework 使用教程
  • 【调试笔记-20240606-Linux-为 OpenWrt 的 nginx 服务器添加Shell CGI 支持】
  • flink实战--⼤状态作业调优实践指南-Flink SQL 作业篇
  • 数据结构:顺序串
  • 掌握复选框(Checkbox)的奥秘:全选与反选功能实现
  • 一篇文章带你搞懂C++引用(建议收藏)
  • 查询SQL:文章浏览1
  • android 在onCreate方法中获得view的宽高
  • SOA主要协议和规范
  • 30、matlab现代滤波:维纳滤波/LMS算法滤波/小波变换滤波
  • HTML5 视频 Vedio 标签详解
  • 三十五篇:数字化转型的引擎:赋能企业的ERP系统全景
  • 利用ArcGIS对长江三角洲地区的gdp水平进行聚类
  • 释放视频潜力:Topaz Video AI for mac/win 一款全新的视频增强与修复利器
  • MongoDB 正则表达式详解:高效数据查询与处理技巧
  • 第二十六章HTML与CSS书写规范
  • 基于FPGA的AD5753(DAC数模转换器)的控制 II(SPI驱动)
  • 【全开源】Java同城服务同城信息同城任务发布平台小程序APP公众号源码
  • [Redis]List类型
  • export 和 export default 的区别
  • 29网课交单平台 epay.php SQL注入漏洞复现
  • 推荐ChatGPT4.0——Code Copilot辅助编程、Diagrams: Show Me绘制UML图、上传PDF并阅读分析
  • rollup.js(入门篇)
  • 【Spring Cloud Alibaba】开源组件Sentinel
  • Android14 WMS-窗口绘制之relayoutWindow流程(一)-Client端
  • JVM学习-Jprofiler
  • Skins
  • 【Meetup】探索Apache SeaTunnel的二次开发与实战案例
  • 嵌入式Linux系统中RTC应用的操作详解
  • Edge 工作区是什么?它都有哪些作用?