Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid argument supplied for foreach() (php 7.1, 7.2, 7.3) Or Trying to access array offset on value of type int (php 7.4) #15

Closed
hiimike opened this issue Aug 30, 2020 · 4 comments

Comments

@hiimike
Copy link

hiimike commented Aug 30, 2020

Hi guys, really good library to get easy of Openvidu. I found an issue with method fetch in Session.php class (to get all active connections, publishers etc.) and I think this is probably by new version of OpenVidu Server :2.15.0,
There is expected a certain json, but my theory is that json structure has been changed from openvidu server response. now I got this from /api/sessions
"connections": { "numberOfElements": 1, "content": [ { "connectionId": "con_YygXCxrtLm", "createdAt": 1598756663749, "location": "unknown", "platform": "Chrome 85.0.4183.83 on OS X 10.15.5 64-bit", "token": "wss://localhost:4443?sessionId=hsD0Tck5z5LMbiSG9oUV&token=tok_QBlmW8FFywHfXY8f&role=PUBLISHER&version=2.15.0", "role": "PUBLISHER", "serverData": "{}", "clientData": "{\"clientData\":\"\"}", "publishers": [ { "createdAt": 1598756665627, "streamId": "str_CAM_FoQc_con_YygXCxrtLm", "mediaOptions": { "hasAudio": true, "audioActive": true, "hasVideo": true, "videoActive": true, "typeOfVideo": "CAMERA", "frameRate": 30, "videoDimensions": "{\"width\":640,\"height\":480}", "filter": {} } } ], "subscribers": [] } ] }

I think previously the elements "numberOfElements" and "mediaOptions" was not present.
Anyways my solution was:

FromArray method Session.php class

if (array_key_exists('connections', $sessionArray)) { foreach ($sessionArray['connections']['content'] as $connection) { $publishers = []; $ensure = $connection['content'] ?? $connection; foreach ($ensure['publishers'] as $publisher) { $publishers[] = PublisherBuilder::build($publisher); } $subscribers = []; foreach ($ensure['subscribers'] as $subscriber) { $subscribers[] = $subscriber->streamId; } $this->activeConnections[] = ConnectionBuilder::build($ensure, $publishers, $subscribers); }

and in builder for publishers

public static function build(array $properties) { return new Publisher($properties['streamId'], $properties['createdAt'], $properties['mediaOptions']['hasAudio'], $properties['mediaOptions']['hasVideo'], $properties['mediaOptions']['audioActive'], $properties['mediaOptions']['videoActive'], $properties['mediaOptions']['frameRate'], $properties['mediaOptions']['typeOfVideo'], $properties['mediaOptions']['videoDimensions'] ); }

my env.
Apache with php 7.4, Openvidu docker image v 2.15.0

@gorlovka
Copy link

true for me too

@jcancig
Copy link
Member

jcancig commented Sep 15, 2020

Hello @hiimike and @gorlovka , the current version of the repository gives 100% support up to version 2.12, 2.13 and partially to 2.14.
Today we will start the changes to give full support to version 2.15, when we have it ready we will let you know.
Thank you very much, for your hiimike proposal

@jcancig jcancig closed this as completed Sep 15, 2020
@hiimike
Copy link
Author

hiimike commented Sep 17, 2020

I tested with 2.13 version of openvidu-server, but unfortunately I got the same error, also another thing is regarding startRecording and stopRecording methods that I already solved on my local.

@jcancig
Copy link
Member

jcancig commented Sep 18, 2020

Hi @hiimike, please update your package to version 1.1.5, this issue has been fixed.
What is the error you found in the recording process? I've done multiple tests and I can't find any problem.
Could you indicate the configuration of your recordings (COMPOSED, CUSTOM LAYOUT,...)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants