简体   繁体   English

如何统一解决SmartFoxServer连接错误

[英]How to resolve SmartFoxServer connection error in unity

I'm using SmartFoxServer API on Unity3d. 我在Unity3d上使用SmartFoxServer API。 It was working fine before I recovered my MacBook, but now gives a connection error as below: 在我恢复MacBook之前它工作正常,但现在出现如下连接错误:

Http error creating http connection: System.Net.Sockets.SocketException: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, Int32 port) [0x00000] in <filename unknown>:0 
UnityEngine.Debug:Log(Object)
SFS2X_Connect:OnConnection(BaseEvent) (at Assets/SFS2X_Connect.cs:2758)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
SFS2X_Connect:Update() (at Assets/SFS2X_Connect.cs:2764)

Here is the connection code: 这是连接代码:

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using System.Collections;
using Sfs2X;
using Sfs2X.Core;

    public class SFS2X_Connect : MonoBehaviour {

        public string Host = "127.0.0.1";

        [Tooltip("TCP port listened by the SmartFoxServer 2X instance; used for regular socket connection in all builds except WebGL")]
        public int TcpPort = 9933;

        [Tooltip("WebSocket port listened by the SmartFoxServer 2X instance; used for in WebGL build only")]
        public int WSPort = 8888;

        [Tooltip("Name of the SmartFoxServer 2X Zone to join")]
        public string Zone = "examplezone";


    SmartFox sfs;

          sfs = new SmartFox ();

          sfs.ThreadSafeMode = false;

         sfs.AddEventListener (SFSEvent.CONNECTION, OnConnection);

        ConfigData cfg = new ConfigData();

        cfg.Host = Host;
        cfg.Port = TcpPort;
        cfg.Zone = Zone;

        sfs.Connect (cfg);
    }

I've removed and re-imported smartfox.dll but still encounter the same error. 我已删除并重新导入smartfox.dll但仍遇到相同的错误。

What can I do? 我能做什么?

Note: I create a new project and imported SnartFoxServer. 注意:我创建了一个新项目并导入了SnartFoxServer。 It's connected to the server. 它连接到服务器。

区域名称确实存在, forceBlueBoxOverHttpstrue因为apple不接受HTTP连接。

cfg.forceBlueBoxOverHttps = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM