使用prismarine-proxy连接Hypixel时出现错误求助
Hypixel代理连接失败问题排查与解决
我的代理代码
const { InstantConnectProxy } = require('prismarine-proxy') const proxy = new InstantConnectProxy({ loginHandler: (client) => { // client object has a username object, so you can store usernames with their respective logins return { username: "D3P_", auth: "microsoft", } // the login the proxy will connect to the server with }, serverOptions: { // options for the local server shown to the vanilla client version: '1.8.9', port: 25565, }, clientOptions: { // options for the client that will connect to the proxied server version: '1.8.9', host: 'mc.hypixel.net' // server the proxy will connect to } }) proxy.on('incoming', (data, meta, toClient, toServer) => { // packets incoming from the server to the client if (meta.name === 'world_particles') return // for 1.8.9, world_particles is the packet that contains particles, so by returning here, the client connected to the proxy won't get any particles toClient.write(meta.name, data) // otherwise send the packet to the client }) proxy.on('outgoing', (data, meta, toClient, toServer) => { // packets outgoing from the client to the server if (meta.name === 'chat') console.log(data.message) // for 1.8.9, chat is the packet that the client sends to send a chat message to the server, so by using console.log, we can sniff the message before it hits the server, and even return early so it wouldn't hit the server toServer.write(meta.name, data) // otherwise send the packet to the client })
连接时出现的错误
Disconnected java.net.ConnectionException: Connection refused: no further information Internal Exception: io.netty.handler.codec.DecoderException: java.io.IOException: Bad packet id 1280
还会随机出现out of bounds相关错误。
环境说明
- 使用Lunar Client 1.8.9
- 代码基于prismarine-proxy官方文档修改,仅将认证方式改为Microsoft(官方说明支持该选项)
可能的解决方向
1. 检查端口占用与连接配置
- 确保本地代理端口25565未被其他程序占用,比如本地Minecraft服务器或其他代理工具
- 尝试修改
serverOptions.port为其他未被占用的端口(如25566),然后客户端连接对应端口
2. 处理Lunar Client的特殊协议
Lunar Client会发送非标准的Minecraft数据包(比如客户端标识、模组数据),prismarine-proxy的InstantConnectProxy可能无法正确解析这些自定义数据包,导致Bad packet id错误:
- 在
outgoing事件中过滤Lunar的自定义数据包:先打印所有meta.name和数据包ID,找出Lunar专属的数据包并跳过转发,避免触发服务器端的解码错误 - 示例修改:
proxy.on('outgoing', (data, meta, toClient, toServer) => { // 打印所有数据包信息,排查异常包 console.log('Outgoing packet:', meta.name, meta.id); // 跳过Lunar的自定义数据包(根据实际打印的ID调整) if (meta.id === 1280) return; if (meta.name === 'chat') console.log(data.message); toServer.write(meta.name, data); })
3. 验证Microsoft认证配置
- 确保你的Node.js环境已正确配置Microsoft认证所需的依赖,prismarine-auth可能需要额外配置才能正常工作
- 尝试使用离线模式(
auth: 'offline')测试代理是否能正常连接,排除认证环节的问题
4. 版本兼容性问题
虽然指定了1.8.9,但prismarine-proxy的版本可能与1.8.9的数据包解析存在兼容性问题:
- 检查prismarine-proxy和prismarine-client的版本,确保使用适配1.8.9的稳定版本
- 执行
npm list prismarine-proxy查看版本,尝试降级或升级到官方推荐的对应版本
替代方案
如果上述方法无法解决问题,可以考虑以下代理工具:
- Mineflayer Proxy:基于mineflayer的代理框架,对自定义客户端的兼容性更好,支持更多数据包拦截与修改操作
- Waterfall/Bungeecord:Java端的代理服务器,适合搭建多服务器代理,对第三方客户端(如Lunar)的兼容性更强,可通过插件实现数据包监听与修改
- ProxyPass:轻量级Minecraft代理工具,支持数据包过滤与转发,配置简单
内容的提问来源于stack exchange,提问作者solarity
相关产品推荐
相关产品推荐

