开发IM问题记录

技术选型

  1.网关spring co zuul 转发ws 会自动降级,替换成spring cloud gayway 即可

spring:
  freemarker:
    checkTemplateLocation: false
  application:
    name: gateway
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
      httpclient:
        websocket:
          max-frame-payload-length: 3000000
      globalcors:
        corsConfigurations:
          '[/**]':
            allowedHeaders: "*"
            allowedMethods: "*"
            allowedOrigins: "*"
            allowCredentials: true
            maxAge: 3600
    #   default-filters:
    #     - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
      routes:
        - id: sms.sev
          uri: lb://sms.sev
          predicates:
            - Path=/sms/**
          filters:
            - StripPrefix=1
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
        - id: sms.zuul.sev
          uri: lb://sms.sev
          predicates:
            - Path=/zuul/sms/**
          filters:
            - StripPrefix=2
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST      
        - id: authx.sev
          uri: lb://pms.authx.sev
          predicates:
            - Path=/authx/**
          filters:
            - StripPrefix=1
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
        - id: authx.admin
          uri: lb://pms.authx.admin
          predicates:
            - Path=/axan/**
          filters:
            - StripPrefix=1
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
        - id: esign
          uri: lb://esi.sev
          predicates:
            - Path=/esign/**
          filters:
            - StripPrefix=1
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
        - id: rbac
          uri: lb://rbac.sev
          predicates:
            - Path=/rbac/**
          filters:
            - StripPrefix=1
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
        - id: vxchat
          uri: lb://vxchat.sev
          predicates:
            - Path=/vxchat/**
        - id: gateway
          uri: lb://pms.gw.sev
          predicates:
            - Path=/gw/**
          filters:
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST  
        - id: fms
          uri: lb://fms.sev
          predicates:
            - Path=/fms/**
          filters:
            - StripPrefix=1
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST
        - id: im.sev.ws
          uri: lb:ws://im.sev
          predicates:
            - Path=/im/ws/**
          filters:
            - StripPrefix=2
        - id: im.sev.http
          uri: lb://im.sev
          predicates:
            - Path=/im/http/**
          filters:
            - StripPrefix=2
            - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST

  2.后端使用底层为netty的webflux

遇到的问题

01. 网关配置跨域问题后 ws 无法访问

如上配置中注释的部分 : 

#   default-filters:
    #     - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST

注释掉,节点单独配即可

02. nginx 代理会让ws 无法保存长连接,所以需要ping-pong

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>