From 29ef46b7a06a1c31fcec661efe7dc0f43184fa03 Mon Sep 17 00:00:00 2001 From: heavyrian2012 Date: Fri, 5 Sep 2025 20:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E5=92=8C=E9=A2=91=E9=81=93sdk=E6=A3=80=E6=9F=A5=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wildfirechat/sdk/utilities/ChannelHttpUtils.java | 10 +++++++--- .../cn/wildfirechat/sdk/utilities/RobotHttpUtils.java | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java index 98c5dea0..4d300707 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java @@ -42,7 +42,7 @@ public class ChannelHttpUtils extends JsonUtils implements Closeable { private final int port; private void checkPort() { - if (port != 80 && port != 443) { + if (port != 80 && port != 443 && port != -1) { if (port == 18080) { LOG.warn("您传入的频道API地址中的端口是18080,18080端口默认为管理API端口,频道API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!"); } else { @@ -56,8 +56,12 @@ public class ChannelHttpUtils extends JsonUtils implements Closeable { this.channelId = channelId.trim(); this.channelSecret = secret.trim(); try { - URL url = new URL(this.imurl); - this.port = url.getPort(); + URL u = new URL(this.imurl); + int port = u.getPort(); + if(port == -1) { + port = u.getDefaultPort(); + } + this.port = port; } catch (MalformedURLException e) { throw new RuntimeException(e); } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java index f8cf3b35..4333cd49 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java @@ -43,7 +43,7 @@ public class RobotHttpUtils extends JsonUtils implements Closeable { private final int port; private void checkPort() { - if (port != 80 && port != 443) { + if (port != 80 && port != 443 && port != -1) { if (port == 18080) { LOG.warn("您传入的机器人API地址中的端口是18080,18080端口默认为管理API端口,机器人API端口应该为IM服务的HTTP端口,默认为80,请确认是否使用错误!"); } else { @@ -58,7 +58,11 @@ public class RobotHttpUtils extends JsonUtils implements Closeable { this.robotSecret = robotSecret.trim(); try { URL u = new URL(this.url); - this.port = u.getPort(); + int port = u.getPort(); + if(port == -1) { + port = u.getDefaultPort(); + } + this.port = port; } catch (MalformedURLException e) { throw new RuntimeException(e); }