WWBN / AVideo

Create Your Own Broadcast Network With AVideo Platform Open-Source. OAVP OVP
https://avideo.tube/AVideo_OpenSource
Other
1.9k stars 971 forks source link

Iframe Embed gives error on WP website. #8129

Closed guymass closed 1 year ago

guymass commented 1 year ago

I am trying to embed some videos on WP website using the elementor HTML component. At first all videos loaded just fine and everything was playing. Than after embeding few videos I got the following error on all embeds and now non of them load or work anymore. I don't know really what happened, I was just copying the embed code from the video.

All CSP headers to allow iframe embeds between the two sites and domains are set and working. Here is the error screen shot:

Screen Shot 2023-06-27 at 1 15 14

INSERT INTO videos_statistics (when,ip, users_id, videos_id, lastVideoTime, created, modified, session_id) values (now(),?,NULL,?,0,now(),now(),'6g7qrt5n329kstaq9pnbmgooae') Save Video Statistics Error : (0)

This is the url of the embeded video, its a staging area where I edit the site before I push the updates.

https://woocommerce-942083-3360953.cloudwaysapps.com/rosh-hashana-2/

DanielnetoDotCom commented 1 year ago

check if all your plugins have the tables installed.

if they are check your avideo.log for more clues

GreenDragonTavern commented 1 year ago

@guymass try adding this to your theme's functions.php (or child-theme if applicable):

wp_oembed_add_provider( 'https://YourAVideoDomain.com/*', 'https://YourAVideoDomain.com/oembed/', false );

guymass commented 1 year ago

@GreenDragonTavern Thanks for the suggestion, are you sure this is how to add it in the functions.php file?

don't I need to use something like : add_action( 'wp_enqueue_scripts', function () {}

guymass commented 1 year ago

OK I disabled VideoStatistics plugin and now the iframe is working again. Something is causing this bug in that plugin. You can see the video is working now.

https://woocommerce-942083-3360953.cloudwaysapps.com/rosh-hashana-2/

For this specific embeds I don't need that plugin so for now I will keep it disabled. and maybe test again in future updates.

guymass commented 1 year ago

Just to add, on Safari Browser I still see the error even after clearing cache and the videos statistics plugin is disabled.

Screen Shot 2023-06-27 at 11 00 38

On Chrome I can open it, but some friend who also opens the URL get the error so im not sure where the issue is. Maybe. a CSP?

Screen Shot 2023-06-27 at 11 27 09

guymass commented 1 year ago

I see this in the avideo.log file:

Screen Shot 2023-06-27 at 11 51 38

guymass commented 1 year ago

What is this "Data too long for column 'ip'"

DanielnetoDotCom commented 1 year ago

the IP supposed to be IPv4, you are probably using IPv6. try to disable IPv6 in your server.

guymass commented 1 year ago

This site is running as a VM server running under PROXMOX virtualization. This is the only connection I have on this server, hjow would I disable IPv6?

Screen Shot 2023-06-27 at 16 28 54

And I connect to it using reverse ssh proxy tunnel

guymass commented 1 year ago

I disabled IPv6 but still seee the same error it domes and goes. We notices that the Checkmark for "Share my videos" on the videos page sometimes gets reset to disable, so I enable it again, but still all EMbeds give me this error but not from all browsers and you might be able to open and view it while I cannot locally. Very strange.

more from log: Screen Shot 2023-06-27 at 16 45 09

guymass commented 1 year ago

Now its back again I don't knoiw for how long it will hold. Can you open this URL and view the video at the bottom, does it open for you?

https://woocommerce-942083-3360953.cloudwaysapps.com/holidays-summer/

On Safari it still give me that error, Chrome opens it on one computer but not on another, Brave same as chrome.

DanielnetoDotCom commented 1 year ago

image

What error in safari?

check the Safari JS log

guymass commented 1 year ago

it seems to work now, I only have a problem on one computer that for some reason doesn't load it in brave and one in Safari, but the rest work so this could be internal issue in my LAN as well idk. I will keep checking, the console doesn't show anything on both browsers. All I get is this:

Screen Shot 5783-10-08 at 17 57 34

So idk why some can open and other's don't, but as long as it loads externally then it will show on the page. For now I will keep it open if I have more info.

** Brave JS console shows this but I don't think its related. Screen Shot 5783-10-08 at 18 06 28

DanielnetoDotCom commented 1 year ago

I am pretty sure you have a plugin missing table installation.

but check your avideo.log

guymass commented 1 year ago

Ok I see in log it is asking me about a Plugin newletter not found error, which I don't have and don't know why I need it. I went through all plugins setting them to on/off to see if any missing tables and didn't see any.

What I did notice is this, if I am logged in with the use from which I am copying the embed code the videos show up, if the session ends or I log off or log in with a different use the embeds don't work anymore for that user even though Share is enabled and video is public.

Could this be related to the user having to be logged in? maybe the user session is effecting how the embeds are shared?

It comes and goes, suddenly showing for me but not for my friend or it will load on one computer but not the other and it could be because the session ends after a short while and then all the user's embeds stop working/loading.

guymass commented 1 year ago

Just in case I have went over all plugins again and disabled and enabled them all, then set again my selections and cleared all cache, but as long as the user was still disconnected from the site the embeds didn't work for me, only after I logged in did they show up. However even when I was logged in the same video didn't show up for my friend.

I am sure I have no missing tables unless something on the site requires a certain plugin, maybe this newletter idk.

guymass commented 1 year ago

I also forgot to mention, this domain is also going through MediaFire, however they have set all headers for me to allow iframe to work both ways between the domain and its sub domain. Other than that the videos load up for me only when that user is logged in. It seems either it disregards the "Allow share my videos" check mark or some other issue idk yet.

DanielnetoDotCom commented 1 year ago

Ok I see in log it is asking me about a Plugin newletter not found error, which I don't have and don't know why I need it. I went through all plugins setting them to on/off to see if any missing tables and didn't see any.

I have no idea what is the newsletter plugin, I have never had one, it is probably something in your WP

Could this be related to the user having to be logged in? maybe the user session is effecting how the embeds are shared?

logged in where? WP or AVideo?

It comes and goes, suddenly showing for me but not for my friend or it will load on one computer but not the other and it could be because the session ends after a short while and then all the user's embeds stop working/loading.

You need to provide a clue, and check your JS console and your avideo.log, without a good clue, I cannot help

guymass commented 1 year ago

Like I said and you can see it in the log screenshot, the newsletter error comes from the avideo.log file a not the WP. Also I am log in to the AVideo site and only while I log in do the embeds of that user work. Once the session timesout the embeds stop working then I need to refresh and login again to the AVideo site to make the embeds work.

Also changing the session number to a higher value then 3600 doesn't do anything and the session still end after around 30 min.

From what I can tell, only when the user is logged in to the AVideo site do his embeds work externally on my WP site.

DanielnetoDotCom commented 1 year ago

like I said before, we never had anything related to a newsletter , it MUST be something you did

guymass commented 1 year ago

What could I possibly do? this is a simple straight forward installation, I just uploaded a video to the channel and copied the Embed code and pasted it inside an HTML component of WP elementor. Nothing else was done, a simple copy paste.

From what I can tell this newletter thing is not the issue. This related to the user session. How can I extend the session timeout to be infinite? I tried changing the value for the session but it seems to not effect it at all, the session still ends after about 30m of being idle.

DanielnetoDotCom commented 1 year ago

Do not extend it.

what exactly error are you having now? In this thread you start talking about a SQL error, then a plugin error (Newsletter) and you are talking about a session timeout. I am totally confused.

guymass commented 1 year ago

OK, the main issue is that video Embeds in iframe stop loading when the user session ends. When this happens it shows this SQL error about video statistics. Than when I view the avideo.log it shows those errors I posted hoping you will understand more then me what the logs say. I was only passing the info to you, I wasn't saying anything about newsletter, it was just showing in the avideo.log.

So far from what I have experienced with this issue it related to the user session, because once the session ends those iframe Embeds don't work. They only work or the video only loads when the user is logged into the AVideo site. So IMO this is something to do with the session or the user having to be logged in and connected to the AVideo site in order for their iframe Embed to work.

DanielnetoDotCom commented 1 year ago

ok, your issue is the SQL error, forget everything else until it is fixed

to resolve the SQL error we need something from your avideo.log file.

guymass commented 1 year ago

well this error only appears when the user is logged off. Now I need to mention something I only noticed now. I never used the "Remember Me" switch with this user, I didn't save for it the password. Every time I needed to use it I just typed in the password and logged in. Maybe this also could be the reason it keeps logging off the user out. So now I used that check mark and had my browser save the password for quick login and I hope that now it will not logoff the user after 30m. I see the session is set to 3600, maybe also this is to short?

I think the SQL error happens because it cannot connect to the account and load the video into the iframe when the user is logged off. So what is the correlation between the iframe connecting to the site and loading the shared video and not being able to load it if the user is not logged into the AVideo site?

Shared content which is public should be allowed in the iframe regardless if the channel's user is connected or not, so something is breaking that connection or is blocking it when the user is not logged into the AVideo site.

This IMO has nothing to do with the WP site itself, it only loads the iframe inside an HTML block on a page.

guymass commented 1 year ago

Also we have two types of embed, the iframe which can also load the chat and maybe this is the problem with the user not being logged in and why the iframe breaks.

The second is an embed of Object which should only load the video without the chat. Both embeds behave the same way and stop showing the embedded video when the channel's user from which the video is shared is disconnected from the AVideo site.

DanielnetoDotCom commented 1 year ago

image

guymass commented 1 year ago

I think what I did fixed it. Going to leave it for few more hours like that and check again when i am back. If it will still loads my video then I think the entire issue was because I didn't use the "Remember Me" check mark when I log in.

guymass commented 1 year ago

Ok im back after 4 hours and its working. Seems that the "Remember Me" checkbox is important for keeping the user logged in. Now my user is logged in without disconnecting for over 10 hours and looks like this issue is gone!

Like I said this is not a SQL error, this has something to do with the way content is shared and embeded from AVideo site. I will keep this post open for another day or too just to make sure, but for now it seems to be working for me, I still haven't checked with friends from external connections, I will post if there are any issues from them.

guymass commented 1 year ago

It seems that my friend still cannot load it and sees the SQL error and I also see it when I try to load it in my mobile.

Here is the URL again:

https://woocommerce-942083-3360953.cloudwaysapps.com/rosh-hashana-2/

So it only works for me from the computer from which I logged in to avideo site. I can view the video on that URL but no one else can. I don't see anything in the logs other then what I already posted, same errors. I will keep checking but for now idk. It keeps complaining about videos_statistics.

DanielnetoDotCom commented 1 year ago

try this https://github.com/WWBN/AVideo/issues/8129#issuecomment-1609488164

DanielnetoDotCom commented 1 year ago

Here is working fine

image

can you run this in your MySQL ?

DESCRIBE videos_statistics;

I want to check the length of the IP column

guymass commented 1 year ago

IP column is VARCHAR (45) and I already disabled IPv6.

DanielnetoDotCom commented 1 year ago

Ok, it should handle IPv6, so you MUST find something in the avideo.log regarding videos_statistics table

guymass commented 1 year ago

This is my log so far maybe you will be able to find something in it. avideo.log

DanielnetoDotCom commented 1 year ago

nothing in your log, you should do this ... delete your log, go to the page where you get the SQL error, then share your log again

also check the apache log

guymass commented 1 year ago

On a clean avideo.log file, while the channel user is NOT logged in / connected to the site, I get this error:

Screen Shot 5783-10-16 at 12 18 06 Screen Shot 5783-10-16 at 12 20 30

No other error is noticed in apache logs. Only once i login with the user of the channel of which those video embed codes are shared will those videos showup on the wordpress page.

So it seems this VideoEmbeded.php on line 108 there is an issue created while the user is offline or disconnected from their account and when they login the video embeds work. IMHO the user session timeout effects the shared embeds in some way idk.

guymass commented 1 year ago

now even with the user logged in i get that error but only on external browsers.

Can you confirm you can still load the video on your end? https://woocommerce-942083-3360953.cloudwaysapps.com/rosh-hashana-2/

This is what I see:

Screen Shot 5783-10-16 at 14 40 18

And I see these new errors in the new avideo.log: Screen Shot 2023-07-05 at 15 08 34

DanielnetoDotCom commented 1 year ago

that is exactly what I think

if you did what you are saying here this error does not make sense

the only way to find your is to inject some code in your view/videoEmbeded.php file

add this code in line 8 of this file:

$sql = "DESCRIBE videos_statistics";
$res = sqlDAL::readSql($sql, "", [], true);
$data = sqlDAL::fetchAssoc($res);
var_dump(getRealIpAddr(), $data);
exit;

image

guymass commented 1 year ago

I added the code see if it shows you anything. I see it this:

string(54) "2a00:a040:1a3:98e8:8de:47da:ed0b:292f, 162.158.254.139" array(6) { ["Field"]=> string(2) "id" ["Type"]=> string(7) "int(11)" ["Null"]=> string(2) "NO" ["Key"]=> string(3) "PRI" ["Default"]=> NULL ["Extra"]=> string(14) "auto_increment" }

DanielnetoDotCom commented 1 year ago

Why did your IP respond this: 2a00:a040:1a3:98e8:8de:47da:ed0b:292f, 162.158.254.139

that means IPv6 is still active and you have IPv6 and IPv4 active at the same time and some extra weird configuration that responds 1 string with both IPs concatenated

but anyway, I will send you an update that will fix it. and prevent this to happen again

DanielnetoDotCom commented 1 year ago

The HTTP_X_FORWARDED_FOR header can often include both IPv4 and IPv6 addresses, separated by commas, when clients are using a proxy server or a load balancer.

DanielnetoDotCom commented 1 year ago

this update may resolve your issue

guymass commented 1 year ago

Great i will update and test hope this will work. I think this is maybe coming from my PROXMOX virtual server which provides the network connections for the VM, I still haven't figured how to disable IPv6 on it and i am not sure I can or should so this fix will definitely allow for more flexible configurations behind proxies.

Much thanks for your help, I will close this post if all works well.