Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Networked Chat experiment

Hey all,
I am trying to build an experiment for simple chat between 2 participants.
One can be the server and other can be the client. I found some samples for OpenSesame 2 but couldn`t find enough data for version 3.2.

Are there any other person who made a similar experiment?


  • edited September 2018

    Creating an experiment like that is possible, but how easy it is depends on the details. What *exactly* do you want to do? How should participants interact? And does the experiment consist only of chatting, or is this embedded in other tasks?


    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

  • Hi Sebastiaan,
    Thanks for the reply, actually it will be part of a larger experiment and connecting two users from separate computers will be part of the task.
    Two users, will try to complete tasks by cooperating with each other. They will be shown different inputs (images, videos or texts).
    They will communicate with each other by sending messages and try to find the answer.

    Is it a bit more clear? I can give more details.

  • Hi Newbee,

    This sounds like a fairly complicated experiment. Doable, but not trivial at all. Given that you don't seem very experienced in coding, I doubt that you'll be able to implement this, not without a large amount of help (more than you'll likely get on the forum). I may be wrong, but that's the feeling I'm getting.

    So how experienced are you, and do you think you'll be able to manage an experiment that will require a considerable amount of Python coding?


    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

  • Hello Sebastiaan,
    I am not very experienced on coding, but I found some walkaround and simplified the experiment.
    A separate application will be used for chat and Opensesame will get input from only one user, which makes things a lot easier. I will work on it and ask for support for any obstacles I met.

  • Hello again Sebastiaan,
    For last couple of days, I tried again to make this experiment work with client and server.
    Now, server and client can make a connection, but they continuously send messages.
    What I want is, when server sends a specific message, client to show screen1 and if server sends another value show screen2.
    This way I try to change screens on client side with feedbacks from the server.
    Attached you can find the simplified experiment, I can not go further than the inline script, because it crashes when I started it.
    Do you have any idea to make it as simple as possible?
    I think establishing the connection and following the steps in the experiment and sending messages when user submit response to the questions which will trigger actions in client side will be what I need. But I couldn`t do it.

  • edited October 2018

    Hello again,
    I made some more changes and now both instances can make the connection but I want the message to be sent to change based on an internal variable (a form input). If this value (var1_1) equals to 33, it should send 30 and if it is some other value it should send 20. But when I run the application I get an error, which is shown below.
    And also, even the input is correct, client always receives 20.

    **Server Script:**
    HOST = ''
    PORT = 8000
    def task5():
        print ('task 5')
    s = socket(AF_INET, SOCK_STREAM)
    s.bind((HOST, PORT))
    conn, addr = s.accept()
    print 'Connected by', addr
    var1_1 = "" 
    result = str(var1_1)
    if result == '33':
        var = '30'
        var = '20'
    while True:
        data = conn.recv(1024)
        print "Received ", repr(data)
        reply = var
        # print (str(data))
        if str(data) == '50':
        elif data == '100':
                print ('client exited')
    **Client Script:**
    from socket import *
    HOST = 'localhost'
    PORT = 8000
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((HOST, PORT))
    def task1():
        print("task one")
        return 'server did task 1'
    def task2():
        print("task two")
        return 'server did task 2'
    var3 =''
    def task3():
        print("task three")
        var3 = '880'
        return 'server did task 3'
    var = '50'
    while True:
        message = var
        print "Awaiting reply"
        reply = s.recv(1024)
        print "Received ", repr(reply)
        # print(repr(reply))
        if reply == '10':
        elif reply == '20':
        elif reply == '30':
        elif reply == 'quit':
    **Error message:**
    Unexpected error
    item-stack: experiment[run].Experiment_1[run].Task_Sequence[run]
    exception type: AttributeError
    exception message: 'str' object has no attribute 'var1_1'
    time: Wed Oct 10 09:01:05 2018
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libqtopensesame\misc\", line 157, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 456, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 103, in execute
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 122, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 51, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 122, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 51, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 122, in run
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 50, in run
        if self.python_workspace._eval(cond):
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\", line 141, in _eval
        return eval(bytecode, self._globals)
      File "<conditional statement>", line 1, in <module>
    AttributeError: 'str' object has no attribute 'var1_1'
  • Hi,

    I haven't look at your experiment, so I can't tell you whether you are on the right track, but the specific problem here is that you are overwriting opensesame's builtin var object. It is needed for the experiment to run properly, so it is really a bad idea to do stuff like that; var = '30'. So, simply use different variable names and you should be fine.

    Good luck,


  • Thanks Eduard,
    Seems like it was one of the main problems, now I changed the name to var_sent instead of var.
    and now it can correctly send the message and close the connection.

Sign In or Register to comment.