Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Using thrift on Unity3d

Discussion in 'Multiplayer' started by enggreys, Oct 28, 2015.

  1. enggreys

    enggreys

    Joined:
    Sep 3, 2015
    Posts:
    5
    Hi, I've been trying to use Thrift on Unity. On one project I try creating a Server which gets some information from the Kinect and on another Unity Project(running in a different computer) I create a client which requests it.

    The problem is that whenever the server starts Unity freezes. Same with the client. It starts and immediately. When the server is stopped, the client unfreezes.

    A second problem is that when I try to start the server again Unity stops working and I need to stop the task from the task manager.

    Do you have any insights on what may be happening here and how to solve it? (specially for the first problem)
    Have you already made a similar application (using thrift for client and server in unity) that could hep me figure out the problem?

    Thanks in advance
     
  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    Have you checked Run In Background in the player settings?
     
  3. enggreys

    enggreys

    Joined:
    Sep 3, 2015
    Posts:
    5
    My project has that option active. The current situation is the following:
    On one computer there is a server and also a client (which connects to localhost).

    On another computer with the same project there is only a client which connects to the server running on the first computer.

    On the first computer there seems to be no problem, the function returns the expected values which are then printed.

    The second computer, however, freezes, and with freezes I mean I can't even stop the running project. It remains frozen until the server stops running. The the project on the second computer continues to run normally. I should probably mention that pinging the first computer works and all firewalls are currently down.

    Any idea what might be happening?
    Thanks
     
  4. enggreys

    enggreys

    Joined:
    Sep 3, 2015
    Posts:
    5
    It does have that option checked.
     
  5. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    check the editor log file and stand-alone-player log file for anything suspicious
     
  6. enggreys

    enggreys

    Joined:
    Sep 3, 2015
    Posts:
    5
    The problem is now fixed. I was using a simple server instead of a multi threaded one. But thank you for your help
     
  7. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    Were you able to get Unity to use Thrift as a Server? I can get it to work as a Client but when I put it as a Sever, it locks up the Editor.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Thrift.Server;
    using Thrift.Transport;
    using System;

    public class CSharpServer : MonoBehaviour
    {

    // Use this for initialization
    void Start()
    {
    Application.runInBackground = true;

    try
    {
    CSharpTutorial.CalculatorHandler handler = new CSharpTutorial.CalculatorHandler();
    Calculator.Processor processor = new Calculator.Processor(handler);
    TServerTransport serverTransport = new TServerSocket(9091);
    TServer server = new TSimpleServer(processor, serverTransport);

    // Use this for a multithreaded server
    //TServer server = new TThreadPoolServer(processor, serverTransport);

    Debug.Log("Starting the server...");
    server.Serve(); // <-- This line locks up the Unity Editor
    }
    catch (Exception x)
    {
    Debug.Log(x.StackTrace);
    }
    Debug.Log("done.");
    }

    }