send image via instant message with pjsua2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all:

Is it possible to send images (or other binary files) via pjsip instant messaging using pjsua2?  I am using pjsip 2.7.1.
I can IM text messages fine, but when I try and send a binary file I get err=171023 (Message too long (PJSIP_EMSGTOOLONG))

I read the FAQ and did quite a bit of searching, so hopefully I'm not missing anything obvious.

Here is the python method I am using:

def send_file(self, buddy, file_path):
        '''sends file via sip IM'''
        (mime_type, mime_encoding) = mimetypes.guess_type(file_path)
        self._logger.debug('mime_type = %s', mime_type)
        self._logger.debug('mime_encoding = %s', mime_encoding)
        if mime_type is None:
            self._logger.debug('could not determine mime type for file %s', file_path)
        else:
            with open(file_path, 'rb') as file_reader:
                file_contents_bytes = file_reader.read()
                file_reader.close()
            self._logger.debug('len(file_contents_bytes) = %s', file_contents_bytes)
            base64_data = codecs.encode(file_contents_bytes, 'base64')
            string_data = base64_data.decode('utf-8')
            send_im_param = pj.SendInstantMessageParam()
            send_im_param.content = string_data
            send_im_param.contentType = mime_type
            buddy.sendInstantMessage(send_im_param)
            self._logger.debug("sent binary instant msg with length %d to %s", len(file_contents_bytes), str(buddy))
            buddy = None
            self._logger.debug('buddy set to None')

And here is a snip from the pj sip logs (I can post the entire log if desired)

begin log snip
08:28:47.195               endpoint  Request msg MESSAGE/cseq=1084 (tdta0x1adf3a8) created.
08:28:47.195           tsx0x1ab82a8  .Transaction created for Request msg MESSAGE/cseq=1084 (tdta0x1adf3a8)
08:28:47.195           tsx0x1ab82a8  Sending Request msg MESSAGE/cseq=1084 (tdta0x1adf3a8) in state Null
08:28:47.195          sip_resolve.c  .Target '192.168.2.102:0' type=Unspecified resolved to '192.168.2.102:5060' type=UDP (UDP transport)
08:28:47.195           tsx0x1ab82a8  .Failed to send Request msg MESSAGE/cseq=1084 (tdta0x1adf3a8)! err=171023 (Message too long (PJSIP_EMSGTOOLONG))
08:28:47.195           tsx0x1ab82a8  .State changed from Null to Terminated, event=TRANSPORT_ERROR
08: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ZhBDiJnPh0C/WK6jObvg0
jqRr2yd4rut9eCkBXLgjZgjDCr5rDjez85c5JO4/TLrpLvxb9qSj9x7W7vofe85H0MbtBJt+OgM1
O9C9mQeKwunsAT2ZPu0p6jll80Dm04zaWZPoUeMZfIcaw79OHOr/DacOnSGvhz+5+z/nm2TweWos
Y3rfiYslCv8TzzH2t9VsS3mUHprCbb7AzJlPUc/JQlbTFDq/fYDEvy5Qp3dbHoz/jOX7ldS/P4rH
76lR5nErldZfcuZ82zPw9PtW8OVx8Gg/mfdHRqBVwFMPevFS78VsWbKJvrPrVPgYizrLOvfy2COR
1HOCFnfC4R4fsHnlDvqHeV+ZBjt58myLso9Z//sC2+v5Xdltm1J28uXX27lU9Ikfmke7VGiQAfIx
mAG1G8Ufm2DJPsrvh/XWP87tZ/fJPMKDy77v3dGyKdLwGd555xn8VXAx7AydJ+zmn7/OkqW0nW9P
/LeCr06A+yNvMX/8/dQsb/aA5SL7F49h5tZMfDpO4b0+TdAo7NeNF6eUmuNfjJq65ZRbSRUvFwXq
BtEMav8NI3/6gBEHzeR5dmTw4344f3n5W/bS32/RM7w8ACw5f/NJ/1WAN9EThtOmlpKKP9zBTltS
3hmk+RS/bztV7IOztO5f/iADAd0ZM+ZxfAqyRv/7xMrFTvxEO3nzNMMnRLNvVByTBv6G+aIbrcaN
pXM9O
08:28:47.222             pjsua_im.h  Unable to send request: Message too long (PJSIP_EMSGTOOLONG) [status=171023]
08:28:47.222           presence.cpp  pjsua_im_send(acc->getId(), &to, &mime_type, &content, &msg_data, user_data) error: Message too long (PJSIP_EMSGTOOLONG) (status=171023) [../src/pjsua2/presence.cpp:172]

Thank you in advance for any help.
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux